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