feat(test|api): add ExcerptSearch tests

This commit is contained in:
Phan An 2022-07-26 22:36:48 +02:00
parent 705e135f1c
commit e86cdf5131
No known key found for this signature in database
GPG key ID: A81E4477F0BB6FDC
3 changed files with 31 additions and 2 deletions

View file

@ -6,7 +6,7 @@ use App\Models\Album;
class AlbumTest extends TestCase
{
private const JSON_STRUCTURE = [
public const JSON_STRUCTURE = [
'type',
'id',
'name',

View file

@ -6,7 +6,7 @@ use App\Models\Artist;
class ArtistTest extends TestCase
{
private const JSON_STRUCTURE = [
public const JSON_STRUCTURE = [
'type',
'id',
'name',

View file

@ -0,0 +1,29 @@
<?php
namespace Tests\Feature\V6;
use App\Models\Album;
use App\Models\Artist;
use App\Models\Song;
class ExcerptSearchTest extends TestCase
{
public function testSearch(): void
{
Song::factory()->create(['title' => 'A Foo Song']);
Song::factory(6)->create();
Artist::factory()->create(['name' => 'Foo Fighters']);
Artist::factory(3)->create();
Album::factory()->create(['name' => 'Foo Number Five']);
Album::factory(4)->create();
$this->getAsUser('api/search?q=foo')
->assertJsonStructure([
'songs' => ['*' => SongTest::JSON_STRUCTURE],
'artists' => ['*' => ArtistTest::JSON_STRUCTURE],
'albums' => ['*' => AlbumTest::JSON_STRUCTURE],
]);
}
}