2022-10-21 20:06:43 +00:00
|
|
|
import { expect, it } from 'vitest'
|
|
|
|
import factory from '@/__tests__/factory'
|
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
|
|
|
import { http } from '@/services'
|
|
|
|
import { genreStore } from '@/stores/genreStore'
|
|
|
|
|
|
|
|
new class extends UnitTestCase {
|
|
|
|
protected test () {
|
|
|
|
it('fetches all genres', async () => {
|
2024-06-01 18:02:27 +00:00
|
|
|
const genres = factory('genre', 3)
|
2022-10-21 20:06:43 +00:00
|
|
|
this.mock(http, 'get').mockResolvedValue(genres)
|
|
|
|
|
|
|
|
expect(await genreStore.fetchAll()).toEqual(genres)
|
|
|
|
})
|
|
|
|
|
|
|
|
it('fetches a single genre', async () => {
|
2024-06-01 18:02:27 +00:00
|
|
|
const genre = factory('genre')
|
2022-10-21 20:06:43 +00:00
|
|
|
this.mock(http, 'get').mockResolvedValue(genre)
|
|
|
|
|
|
|
|
expect(await genreStore.fetchOne(genre.name)).toEqual(genre)
|
|
|
|
expect(http.get).toHaveBeenCalledWith(`genres/${genre.name}`)
|
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|