mirror of
https://github.com/koel/koel
synced 2024-12-20 17:43:36 +00:00
25 lines
776 B
TypeScript
25 lines
776 B
TypeScript
|
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 () => {
|
||
|
const genres = factory<Genre>('genre', 3)
|
||
|
this.mock(http, 'get').mockResolvedValue(genres)
|
||
|
|
||
|
expect(await genreStore.fetchAll()).toEqual(genres)
|
||
|
})
|
||
|
|
||
|
it('fetches a single genre', async () => {
|
||
|
const genre = factory<Genre>('genre')
|
||
|
this.mock(http, 'get').mockResolvedValue(genre)
|
||
|
|
||
|
expect(await genreStore.fetchOne(genre.name)).toEqual(genre)
|
||
|
expect(http.get).toHaveBeenCalledWith(`genres/${genre.name}`)
|
||
|
})
|
||
|
}
|
||
|
}
|