fix(tests): make frontend tests compatible with current frontend setup
This commit is contained in:
parent
ea0de43ad6
commit
ed4b923b1e
6 changed files with 129 additions and 22 deletions
9
front/test/setup/mock-audio-context.ts
Normal file
9
front/test/setup/mock-audio-context.ts
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
import { AudioContext } from 'standardized-audio-context-mock'
|
||||
import { vi, beforeAll } from 'vitest'
|
||||
|
||||
beforeAll(() => {
|
||||
vi.mock('standardized-audio-context', () => ({
|
||||
AudioContext
|
||||
}))
|
||||
})
|
||||
|
||||
14
front/test/setup/mock-vue-i18n.ts
Normal file
14
front/test/setup/mock-vue-i18n.ts
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
import { config } from '@vue/test-utils'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import en from '~/locales/en_US.json'
|
||||
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'en',
|
||||
messages: {
|
||||
en
|
||||
}
|
||||
})
|
||||
|
||||
config.global.plugins ??= []
|
||||
config.global.plugins.push(i18n)
|
||||
|
|
@ -3,7 +3,8 @@ import AlbumDetail from '~/views/admin/library/AlbumDetail.vue'
|
|||
import SanitizedHtml from '~/components/SanitizedHtml.vue'
|
||||
import HumanDate from '~/components/common/HumanDate.vue'
|
||||
|
||||
import moxios from 'moxios'
|
||||
import MockAdapter from 'axios-mock-adapter'
|
||||
import axios from 'axios'
|
||||
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import { sleep } from '?/utils'
|
||||
|
|
@ -11,23 +12,15 @@ import { sleep } from '?/utils'
|
|||
import router from '~/router'
|
||||
import store from '~/store'
|
||||
|
||||
beforeEach(() => moxios.install())
|
||||
afterEach(() => moxios.uninstall())
|
||||
const axiosMock = new MockAdapter(axios)
|
||||
|
||||
describe('views/admin/library', () => {
|
||||
describe('Album details', () => {
|
||||
it('displays default cover', async () => {
|
||||
const album = { cover: null, artist: { id: 1 }, title: 'dummy', id: 1, creation_date: '2020-01-01' }
|
||||
|
||||
moxios.stubRequest('manage/library/albums/1/', {
|
||||
status: 200,
|
||||
response: album
|
||||
})
|
||||
|
||||
moxios.stubRequest('manage/library/albums/1/stats/', {
|
||||
status: 200,
|
||||
response: {}
|
||||
})
|
||||
axiosMock.onGet('manage/library/albums/1/').reply(200, album)
|
||||
axiosMock.onGet('manage/library/albums/1/stats/').reply(200, {})
|
||||
|
||||
const wrapper = shallowMount(AlbumDetail, {
|
||||
props: { id: 1 },
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue