提交一次全量代码
This commit is contained in:
1 parent
855396e553
commit
9fa608f602
58 files changed
+8439
-116
No files matched your search
@@ -0,0 +1,70 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { createPinia } from 'pinia'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
import { createMemoryHistory, createRouter } from 'vue-router'
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
|
||||
import ReservationAppShell from '@/layouts/ReservationAppShell.vue'
|
||||
import enUS from '@/i18n/locales/en-US'
|
||||
import thTH from '@/i18n/locales/th-TH'
|
||||
import zhCN from '@/i18n/locales/zh-CN'
|
||||
|
||||
vi.mock('@/services/healthService', () => ({
|
||||
fetchBackendHealth: vi.fn().mockResolvedValue({
|
||||
status: 'UP',
|
||||
service: 'test',
|
||||
}),
|
||||
}))
|
||||
|
||||
async function mountShell() {
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
fallbackLocale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': zhCN,
|
||||
'en-US': enUS,
|
||||
'th-TH': thTH,
|
||||
},
|
||||
})
|
||||
const router = createRouter({
|
||||
history: createMemoryHistory(),
|
||||
routes: [
|
||||
{
|
||||
path: '/reservation/orders',
|
||||
component: { template: '<div />' },
|
||||
meta: { titleKey: 'nav.orders' },
|
||||
},
|
||||
{
|
||||
path: '/reservation/tasks',
|
||||
component: { template: '<div />' },
|
||||
meta: { titleKey: 'nav.taskQueue' },
|
||||
},
|
||||
],
|
||||
})
|
||||
await router.push('/reservation/orders')
|
||||
await router.isReady()
|
||||
|
||||
return mount(ReservationAppShell, {
|
||||
global: {
|
||||
plugins: [i18n, router, createPinia()],
|
||||
},
|
||||
slots: {
|
||||
default: '<section />',
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
describe('ReservationAppShell', () => {
|
||||
it('switches between Chinese, English, and Thai labels', async () => {
|
||||
const wrapper = await mountShell()
|
||||
|
||||
expect(wrapper.text()).toContain('订单列表')
|
||||
|
||||
await wrapper.findAll('button').find((button) => button.text() === 'ไทย')?.trigger('click')
|
||||
expect(wrapper.text()).toContain('รายการออเดอร์')
|
||||
|
||||
await wrapper.findAll('button').find((button) => button.text() === 'EN')?.trigger('click')
|
||||
expect(wrapper.text()).toContain('Order list')
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user