fix: standardize JSON response format in TextWidgetController and update related tests
This commit is contained in:
parent
224654cabf
commit
d715a177bd
2 changed files with 7 additions and 2 deletions
|
|
@ -14,7 +14,9 @@ class TextWidgetController extends Controller
|
|||
*/
|
||||
public function index()
|
||||
{
|
||||
return TextWidget::with('category')->get()->map(fn ($tw) => new TextWidgetResource($tw));
|
||||
return response()->json([
|
||||
'data' => TextWidget::with('category')->get()->map(fn ($tw) => new TextWidgetResource($tw))
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -14,7 +14,10 @@ test('can list text widgets', function () {
|
|||
$response = $this->actingAs($user)->getJson('/api/text-widgets');
|
||||
|
||||
$response->assertOk()
|
||||
->assertJsonCount(3);
|
||||
->assertJson(fn ($json) =>
|
||||
$json->has('data', 3)
|
||||
->etc()
|
||||
);
|
||||
});
|
||||
|
||||
test('can create a text widget', function () {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue