2022-05-09 09:59:31 +00:00
|
|
|
import { expect, it } from 'vitest'
|
2022-05-11 09:12:26 +00:00
|
|
|
import { commonStore } from '@/stores'
|
2022-05-13 17:58:38 +00:00
|
|
|
import UnitTestCase from '@/__tests__/UnitTestCase'
|
2022-10-26 20:44:44 +00:00
|
|
|
import { http } from '@/services'
|
2022-11-29 10:18:58 +00:00
|
|
|
import { screen, waitFor } from '@testing-library/vue'
|
2022-05-07 09:26:32 +00:00
|
|
|
import AboutKoelModel from './AboutKoelModal.vue'
|
|
|
|
|
2022-05-13 17:58:38 +00:00
|
|
|
new class extends UnitTestCase {
|
2022-10-26 21:39:24 +00:00
|
|
|
private renderComponent () {
|
|
|
|
return this.render(AboutKoelModel, {
|
|
|
|
global: {
|
|
|
|
stubs: {
|
|
|
|
SponsorList: this.stub('sponsor-list')
|
|
|
|
}
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
|
2022-05-09 09:59:31 +00:00
|
|
|
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-05-09 09:59:31 +00:00
|
|
|
|
2022-10-26 21:39:24 +00:00
|
|
|
expect(this.renderComponent().html()).toMatchSnapshot()
|
2022-05-09 09:59:31 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
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'
|
2022-10-26 21:39:24 +00:00
|
|
|
this.actingAsAdmin().renderComponent().getByTestId('new-version-about')
|
2022-05-09 09:59:31 +00:00
|
|
|
})
|
|
|
|
|
2022-10-26 20:44:44 +00:00
|
|
|
it('shows demo notation', async () => {
|
|
|
|
const getMock = this.mock(http, 'get').mockResolvedValue([])
|
2022-08-10 14:56:01 +00:00
|
|
|
// @ts-ignore
|
2022-07-10 15:22:07 +00:00
|
|
|
import.meta.env.VITE_KOEL_ENV = 'demo'
|
2022-10-26 20:44:44 +00:00
|
|
|
|
2022-11-29 10:18:58 +00:00
|
|
|
this.renderComponent()
|
2022-10-26 20:44:44 +00:00
|
|
|
|
|
|
|
await waitFor(() => {
|
2022-11-29 10:18:58 +00:00
|
|
|
screen.getByTestId('demo-credits')
|
2022-10-26 20:44:44 +00:00
|
|
|
expect(getMock).toHaveBeenCalledWith('demo/credits')
|
|
|
|
})
|
2022-05-09 09:59:31 +00:00
|
|
|
})
|
|
|
|
}
|
|
|
|
}
|