Skip to content

Commit

Permalink
chore: clean up and fix some TS
Browse files Browse the repository at this point in the history
  • Loading branch information
phanan committed Sep 14, 2022
1 parent 4306d1e commit 8c452dd
Show file tree
Hide file tree
Showing 26 changed files with 32 additions and 49 deletions.
4 changes: 2 additions & 2 deletions resources/assets/js/components/album/AlbumInfo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ new class extends UnitTestCase {
},
global: {
provide: {
[SongsKey]: [ref(songsToMatchAgainst)]
[<symbol>SongsKey]: [ref(songsToMatchAgainst)]
}
}
})
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/components/artist/ArtistCard.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
})
}
}
6 changes: 3 additions & 3 deletions resources/assets/js/components/artist/ArtistInfo.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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))
})
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/services/authService.spec.ts
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/services/cache.spec.ts
Original file line number Diff line number Diff line change
@@ -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

Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/services/downloadService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/services/mediaInfoService.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/services/playbackService.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { nextTick, reactive } from 'vue'
import plyr from 'plyr'
import lodash from 'lodash'
import { expect, it, vi } from 'vitest'
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'

Expand Down
6 changes: 1 addition & 5 deletions resources/assets/js/services/uploadService.ts
Original file line number Diff line number Diff line change
@@ -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'
Expand Down Expand Up @@ -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)
}
}
2 changes: 1 addition & 1 deletion resources/assets/js/stores/albumStore.spec.ts
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/stores/artistStore.spec.ts
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/stores/commonStore.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/stores/favoriteStore.spec.ts
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/stores/overviewStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/stores/playlistStore.spec.ts
Original file line number Diff line number Diff line change
@@ -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[] = [
{
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/stores/preferenceStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
7 changes: 3 additions & 4 deletions resources/assets/js/stores/queueStore.spec.ts
Original file line number Diff line number Diff line change
@@ -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

Expand Down Expand Up @@ -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])
})
Expand Down
3 changes: 1 addition & 2 deletions resources/assets/js/stores/recentlyPlayedStore.spec.ts
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down
5 changes: 1 addition & 4 deletions resources/assets/js/stores/searchStore.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/stores/settingStore.spec.ts
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down
12 changes: 2 additions & 10 deletions resources/assets/js/stores/songStore.spec.ts
Original file line number Diff line number Diff line change
@@ -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 () {
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/stores/themeStore.spec.ts
Original file line number Diff line number Diff line change
@@ -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',
Expand Down
2 changes: 1 addition & 1 deletion resources/assets/js/stores/userStore.spec.ts
Original file line number Diff line number Diff line change
@@ -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,
Expand Down

0 comments on commit 8c452dd

Please sign in to comment.