Added test

Signed-off-by: snipe <snipe@snipe.net>
This commit is contained in:
snipe 2024-07-11 15:25:26 +01:00
parent a7a1a377da
commit 2b5463475c

View file

@ -54,4 +54,29 @@ class ConsumableIndexTest extends TestCase
->assertResponseDoesNotContainInRows($consumableA) ->assertResponseDoesNotContainInRows($consumableA)
->assertResponseContainsInRows($consumableB); ->assertResponseContainsInRows($consumableB);
} }
public function testConsumableIndexReturnsExpectedSearchResults()
{
Consumable::factory()->count(10)->create();
Consumable::factory()->count(1)->create(['name' => 'My Test Consumable']);
$this->actingAsForApi(User::factory()->superuser()->create())
->getJson(
route('api.consumables.index', [
'search' => 'My Test Consumable',
'sort' => 'name',
'order' => 'asc',
'offset' => '0',
'limit' => '20',
]))
->assertOk()
->assertJsonStructure([
'total',
'rows',
])
->assertJson([
'total' => 1,
]);
}
} }