koel/resources/assets/js/components/meta/AboutKoelModal.spec.ts

37 lines
1.1 KiB
TypeScript
Raw Normal View History

import { expect, it } from 'vitest'
import { commonStore } from '@/stores'
2022-05-13 17:58:38 +00:00
import UnitTestCase from '@/__tests__/UnitTestCase'
import { http } from '@/services'
import { waitFor } from '@testing-library/vue'
import AboutKoelModel from './AboutKoelModal.vue'
2022-05-13 17:58:38 +00:00
new class extends UnitTestCase {
protected test () {
it('renders', async () => {
2022-06-10 10:47:46 +00:00
commonStore.state.current_version = 'v0.0.0'
commonStore.state.latest_version = 'v0.0.0'
2022-07-10 15:22:07 +00:00
expect(this.render(AboutKoelModel).html()).toMatchSnapshot()
})
it('shows new version', () => {
2022-06-10 10:47:46 +00:00
commonStore.state.current_version = 'v1.0.0'
commonStore.state.latest_version = 'v1.0.1'
this.actingAsAdmin().render(AboutKoelModel).getByTestId('new-version-about')
})
it('shows demo notation', async () => {
const getMock = this.mock(http, 'get').mockResolvedValue([])
// @ts-ignore
2022-07-10 15:22:07 +00:00
import.meta.env.VITE_KOEL_ENV = 'demo'
const { getByTestId } = this.render(AboutKoelModel)
await waitFor(() => {
getByTestId('demo-credits')
expect(getMock).toHaveBeenCalledWith('demo/credits')
})
})
}
}