mirror of
https://github.com/koel/koel
synced 2024-11-10 14:44:13 +00:00
chore: clean up and fix some TS
This commit is contained in:
parent
4306d1e6f6
commit
8c452dd0e1
26 changed files with 32 additions and 49 deletions
|
@ -49,10 +49,10 @@ new class extends UnitTestCase {
|
|||
})
|
||||
|
||||
it('triggers showing full wiki for aside mode', async () => {
|
||||
const { queryByTestId } = await this.renderComponent('aside')
|
||||
const { getByTestId, queryByTestId } = await this.renderComponent('aside')
|
||||
expect(queryByTestId('full')).toBeNull()
|
||||
|
||||
await fireEvent.click(queryByTestId('more-btn'))
|
||||
await fireEvent.click(getByTestId('more-btn'))
|
||||
|
||||
expect(queryByTestId('summary')).toBeNull()
|
||||
expect(queryByTestId('full')).not.toBeNull()
|
||||
|
|
|
@ -27,7 +27,7 @@ new class extends UnitTestCase {
|
|||
},
|
||||
global: {
|
||||
provide: {
|
||||
[SongsKey]: [ref(songsToMatchAgainst)]
|
||||
[<symbol>SongsKey]: [ref(songsToMatchAgainst)]
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
@ -74,7 +74,7 @@ new class extends UnitTestCase {
|
|||
await this.tick()
|
||||
|
||||
expect(fetchMock).toHaveBeenCalledWith(artist)
|
||||
expect(playMock).toHaveBeenCalled(songs, true)
|
||||
expect(playMock).toHaveBeenCalledWith(songs, true)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,7 +7,7 @@ import { fireEvent } from '@testing-library/vue'
|
|||
import { playbackService } from '@/services'
|
||||
import ArtistInfoComponent from './ArtistInfo.vue'
|
||||
|
||||
let artist: Album
|
||||
let artist: Artist
|
||||
|
||||
new class extends UnitTestCase {
|
||||
private async renderComponent (mode: MediaInfoDisplayMode = 'aside', info?: ArtistInfo) {
|
||||
|
@ -43,10 +43,10 @@ new class extends UnitTestCase {
|
|||
})
|
||||
|
||||
it('triggers showing full bio for aside mode', async () => {
|
||||
const { queryByTestId } = await this.renderComponent('aside')
|
||||
const { queryByTestId, getByTestId } = await this.renderComponent('aside')
|
||||
expect(queryByTestId('full')).toBeNull()
|
||||
|
||||
await fireEvent.click(queryByTestId('more-btn'))
|
||||
await fireEvent.click(getByTestId('more-btn'))
|
||||
|
||||
expect(queryByTestId('summary')).toBeNull()
|
||||
expect(queryByTestId('full')).not.toBeNull()
|
||||
|
|
|
@ -8,7 +8,7 @@ import CreatePlaylistForm from './CreatePlaylistForm.vue'
|
|||
new class extends UnitTestCase {
|
||||
protected test () {
|
||||
it('submits', async () => {
|
||||
const storeMock = this.mock(playlistStore, 'store').mockResolvedValue(factory<PlaylistFolder>('playlist'))
|
||||
const storeMock = this.mock(playlistStore, 'store').mockResolvedValue(factory<Playlist>('playlist'))
|
||||
const { getByPlaceholderText, getByRole } = await this.render(CreatePlaylistForm)
|
||||
|
||||
await fireEvent.update(getByPlaceholderText('Playlist name'), 'My playlist')
|
||||
|
|
|
@ -31,7 +31,7 @@ new class extends UnitTestCase {
|
|||
it.each<[ArtistAlbumViewMode]>([['list'], ['thumbnails']])('sets layout:%s from preferences', async (mode) => {
|
||||
preferenceStore.artistsViewMode = mode
|
||||
|
||||
const { getByTestId, html } = this.renderComponent()
|
||||
const { getByTestId } = this.renderComponent()
|
||||
|
||||
await waitFor(() => expect(getByTestId('artist-list').classList.contains(`as-${mode}`)).toBe(true))
|
||||
})
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { localStorageService } from '@/services/localStorageService'
|
||||
import { authService } from '@/services/authService'
|
||||
import { expect, it } from 'vitest'
|
||||
import { authService } from './authService'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected test () {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { expect, it, vi } from 'vitest'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { Cache } from '@/services/cache'
|
||||
import { Cache } from './cache'
|
||||
|
||||
let cache: Cache
|
||||
|
||||
|
|
|
@ -40,7 +40,7 @@ new class extends UnitTestCase {
|
|||
'downloads favorites if available',
|
||||
(songs, triggered) => {
|
||||
const mock = this.mock(downloadService, 'trigger')
|
||||
favoriteStore.all = songs
|
||||
favoriteStore.state.songs = songs
|
||||
|
||||
downloadService.fromFavorites()
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@ import factory from '@/__tests__/factory'
|
|||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { cache, httpService } from '@/services'
|
||||
import { albumStore, artistStore } from '@/stores'
|
||||
import { mediaInfoService } from '@/services/mediaInfoService'
|
||||
import { mediaInfoService } from './mediaInfoService'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected test () {
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import { nextTick, reactive } from 'vue'
|
||||
import plyr from 'plyr'
|
||||
import lodash from 'lodash'
|
||||
import { expect, it, vi } from 'vitest'
|
||||
|
@ -5,7 +6,6 @@ import { eventBus, noop } from '@/utils'
|
|||
import router from '@/router'
|
||||
import factory from '@/__tests__/factory'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { nextTick, reactive } from 'vue'
|
||||
import { socketService } from '@/services'
|
||||
import { playbackService } from './playbackService'
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { without } from 'lodash'
|
||||
import { reactive } from 'vue'
|
||||
import { UploadFile, UploadStatus } from '@/config'
|
||||
import { UploadFile } from '@/config'
|
||||
import { httpService } from '@/services'
|
||||
import { albumStore, overviewStore, songStore } from '@/stores'
|
||||
import { logger } from '@/utils'
|
||||
|
@ -102,9 +102,5 @@ export const uploadService = {
|
|||
|
||||
removeFailed () {
|
||||
this.state.files = this.state.files.filter(file => file.status !== 'Errored')
|
||||
},
|
||||
|
||||
getFilesByStatus (status: UploadStatus) {
|
||||
return this.state.files.filter(file => file.status === status)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { expect, it } from 'vitest'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { albumStore, songStore } from '@/stores'
|
||||
import factory from '@/__tests__/factory'
|
||||
import { httpService } from '@/services'
|
||||
import { albumStore, songStore } from '.'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected beforeEach () {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { expect, it } from 'vitest'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { artistStore } from '@/stores'
|
||||
import factory from '@/__tests__/factory'
|
||||
import { httpService } from '@/services'
|
||||
import { artistStore } from '.'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected beforeEach () {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import isMobile from 'ismobilejs'
|
||||
import { reactive } from 'vue'
|
||||
import { httpService } from '@/services'
|
||||
import { playlistFolderStore, playlistStore, preferenceStore, settingStore, themeStore, userStore } from '@/stores'
|
||||
import { playlistFolderStore, playlistStore, preferenceStore, settingStore, themeStore, userStore } from '.'
|
||||
|
||||
interface CommonStoreState {
|
||||
allow_download: boolean
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { expect, it } from 'vitest'
|
||||
import factory from '@/__tests__/factory'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { favoriteStore } from '@/stores'
|
||||
import { httpService } from '@/services'
|
||||
import { favoriteStore } from '.'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected beforeEach () {
|
||||
|
|
|
@ -2,7 +2,7 @@ import { expect, it } from 'vitest'
|
|||
import factory from '@/__tests__/factory'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { httpService } from '@/services'
|
||||
import { albumStore, artistStore, overviewStore, recentlyPlayedStore, songStore } from '@/stores'
|
||||
import { albumStore, artistStore, overviewStore, recentlyPlayedStore, songStore } from '.'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected beforeEach () {
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import factory from '@/__tests__/factory'
|
||||
import { playlistStore } from '@/stores'
|
||||
import { expect, it } from 'vitest'
|
||||
import { cache, httpService } from '@/services'
|
||||
import { playlistStore } from '.'
|
||||
|
||||
const ruleGroups: SmartPlaylistRuleGroup[] = [
|
||||
{
|
||||
|
|
|
@ -2,7 +2,7 @@ import { expect, it } from 'vitest'
|
|||
import factory from '@/__tests__/factory'
|
||||
import { localStorageService } from '@/services'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { preferenceStore } from '@/stores'
|
||||
import { preferenceStore } from '.'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected beforeEach () {
|
||||
|
|
|
@ -1,10 +1,9 @@
|
|||
import { reactive } from 'vue'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { queueStore } from '@/stores/queueStore'
|
||||
import { expect, it } from 'vitest'
|
||||
import factory from 'factoria'
|
||||
import { httpService } from '@/services'
|
||||
import { songStore } from '@/stores/songStore'
|
||||
import { reactive } from 'vue'
|
||||
import { queueStore, songStore } from '.'
|
||||
|
||||
let songs
|
||||
|
||||
|
@ -63,7 +62,7 @@ new class extends UnitTestCase {
|
|||
expect(queueStore.state.songs).toHaveLength(0)
|
||||
})
|
||||
|
||||
it.each([['Playing'], ['Paused']])('identifies the current song by %s state', (state: PlaybackState) => {
|
||||
it.each<[PlaybackState]>([['Playing'], ['Paused']])('identifies the current song by %s state', state => {
|
||||
queueStore.state.songs[1].playback_state = state
|
||||
expect(queueStore.current).toEqual(queueStore.state.songs[1])
|
||||
})
|
||||
|
|
|
@ -1,9 +1,8 @@
|
|||
import { expect, it } from 'vitest'
|
||||
import factory from '@/__tests__/factory'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { songStore } from '@/stores/songStore'
|
||||
import { httpService } from '@/services'
|
||||
import { recentlyPlayedStore } from '@/stores/recentlyPlayedStore'
|
||||
import { recentlyPlayedStore, songStore } from '.'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected test () {
|
||||
|
|
|
@ -3,10 +3,7 @@ import UnitTestCase from '@/__tests__/UnitTestCase'
|
|||
import { reactive } from 'vue'
|
||||
import factory from '@/__tests__/factory'
|
||||
import { httpService } from '@/services'
|
||||
import { songStore } from '@/stores/songStore'
|
||||
import { ExcerptSearchResult, searchStore } from '@/stores/searchStore'
|
||||
import { albumStore } from '@/stores/albumStore'
|
||||
import { artistStore } from '@/stores/artistStore'
|
||||
import { albumStore, artistStore, ExcerptSearchResult, searchStore, songStore } from '.'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected beforeEach () {
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import { expect, it } from 'vitest'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { settingStore } from '@/stores/settingStore'
|
||||
import { httpService } from '@/services'
|
||||
import { settingStore } from '.'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected test () {
|
||||
|
|
|
@ -1,19 +1,11 @@
|
|||
import { reactive } from 'vue'
|
||||
import isMobile from 'ismobilejs'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { expect, it } from 'vitest'
|
||||
import factory from '@/__tests__/factory'
|
||||
import { authService, httpService } from '@/services'
|
||||
import {
|
||||
albumStore,
|
||||
artistStore,
|
||||
commonStore,
|
||||
overviewStore,
|
||||
preferenceStore,
|
||||
songStore,
|
||||
SongUpdateResult
|
||||
} from '@/stores'
|
||||
import { eventBus } from '@/utils'
|
||||
import { reactive } from 'vue'
|
||||
import { albumStore, artistStore, commonStore, overviewStore, preferenceStore, songStore, SongUpdateResult } from '.'
|
||||
|
||||
new class extends UnitTestCase {
|
||||
protected afterEach () {
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import { expect, it } from 'vitest'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { preferenceStore, themeStore } from '@/stores'
|
||||
import { preferenceStore, themeStore } from '.'
|
||||
|
||||
const testTheme: Theme = {
|
||||
id: 'test',
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
import { expect, it } from 'vitest'
|
||||
import UnitTestCase from '@/__tests__/UnitTestCase'
|
||||
import { CreateUserData, UpdateCurrentProfileData, UpdateUserData, userStore } from '@/stores/userStore'
|
||||
import factory from '@/__tests__/factory'
|
||||
import { httpService } from '@/services'
|
||||
import { CreateUserData, UpdateCurrentProfileData, UpdateUserData, userStore } from '.'
|
||||
|
||||
const currentUser = factory<User>('user', {
|
||||
id: 1,
|
||||
|
|
Loading…
Reference in a new issue