Skip to content

Commit

Permalink
add tests
Browse files Browse the repository at this point in the history
  • Loading branch information
igor-kamil committed Nov 28, 2024
1 parent d1bb0e2 commit acc4e0c
Showing 1 changed file with 41 additions and 0 deletions.
41 changes: 41 additions & 0 deletions tests/Feature/Api/V1/ItemsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -326,4 +326,45 @@ public function test_show()
],
]);
}

public function test_search_by_id()
{
$item = Item::factory()->create();
app(ItemRepository::class)->refreshIndex();

$url = route('api.v1.items.index', [
'q' => $item->id,
]);

$this->getJson($url)->assertJson([
'total' => 1,
'data' => [
[
'id' => $item->id,
],
],
]);
}

public function test_search_by_identifier()
{
$item = Item::factory()->create(['identifier' => 'G 3415']);
app(ItemRepository::class)->refreshIndex();

$url = route('api.v1.items.index', [
'q' => 'G 3415',
]);

$this->getJson($url)->assertJson([
'total' => 1,
'data' => [
[
'id' => $item->id,
'content' => [
'identifier' => 'G 3415',
],
],
],
]);
}
}

0 comments on commit acc4e0c

Please sign in to comment.