koel/resources/assets/js/stores/songStore.spec.ts

28 lines
891 B
TypeScript
Raw Normal View History

2022-05-15 14:57:28 +00:00
import UnitTestCase from '@/__tests__/UnitTestCase'
import { expect, it } from 'vitest'
import { songStore } from '@/stores/songStore'
new class extends UnitTestCase {
protected test () {
it('gets a song by ID', () => {
2022-06-10 10:47:46 +00:00
expect(songStore.byId('e6d3977f3ffa147801ca5d1fdf6fa55e')!.title).toBe('Like a rolling stone')
2022-05-15 14:57:28 +00:00
})
it('gets multiple songs by IDs', () => {
const songs = songStore.byIds(['e6d3977f3ffa147801ca5d1fdf6fa55e', 'aa16bbef6a9710eb9a0f41ecc534fad5'])
expect(songs[0].title).toBe('Like a rolling stone')
2022-06-10 10:47:46 +00:00
expect(songs[1].title).toBe('Knockin\' on heaven\'s door')
2022-05-15 14:57:28 +00:00
})
it('sets interaction status', () => {
2022-06-10 10:47:46 +00:00
const song = songStore.byId('cb7edeac1f097143e65b1b2cde102482')!
2022-05-15 14:57:28 +00:00
expect(song.liked).toBe(true)
2022-06-10 10:47:46 +00:00
expect(song.play_count).toBe(3)
2022-05-15 14:57:28 +00:00
})
it('guesses a song', () => {
2022-06-10 10:47:46 +00:00
throw 'Unimplemented'
2022-05-15 14:57:28 +00:00
})
}
}