接入前端P0页面真实接口
This commit is contained in:
40
client/src/tests/ReservationStatusBadge.spec.ts
Normal file
40
client/src/tests/ReservationStatusBadge.spec.ts
Normal file
@@ -0,0 +1,40 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { describe, expect, it } from 'vitest'
|
||||
import { createI18n } from 'vue-i18n'
|
||||
|
||||
import ReservationStatusBadge from '@/components/reservation/ReservationStatusBadge.vue'
|
||||
import zhCN from '@/i18n/locales/zh-CN'
|
||||
|
||||
function mountWithI18n(status: string) {
|
||||
const i18n = createI18n({
|
||||
legacy: false,
|
||||
locale: 'zh-CN',
|
||||
messages: {
|
||||
'zh-CN': zhCN,
|
||||
},
|
||||
})
|
||||
|
||||
return mount(ReservationStatusBadge, {
|
||||
props: {
|
||||
status,
|
||||
},
|
||||
global: {
|
||||
plugins: [i18n],
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
describe('ReservationStatusBadge', () => {
|
||||
it('renders stable status code through i18n label', () => {
|
||||
const wrapper = mountWithI18n('PENDING_CONFIRM')
|
||||
|
||||
expect(wrapper.text()).toContain('待确认')
|
||||
expect(wrapper.classes()).toContain('status-badge--info')
|
||||
})
|
||||
|
||||
it('falls back to the raw code for unknown status', () => {
|
||||
const wrapper = mountWithI18n('UNKNOWN_STATUS')
|
||||
|
||||
expect(wrapper.text()).toContain('UNKNOWN_STATUS')
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user