27 lines
1.1 KiB
TypeScript
27 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
import { mount } from '@vue/test-utils'
|
|
import StatusBadge from '@/shared/components/StatusBadge.vue'
|
|
import { loadingListStatusLabel } from './status'
|
|
|
|
describe('loading list status labels', () => {
|
|
it.each([
|
|
['WAIT_LOADING', '待装柜', 'warning'],
|
|
['EDITING', '预装柜中', 'warning'],
|
|
['LOADING', '拣货中', 'info'],
|
|
['COMPLETED', '装柜完成', 'success'],
|
|
['NEW_LOADING_STATE', '未知状态', 'neutral'],
|
|
])('renders %s with its shared status tone', (status, label, tone) => {
|
|
const wrapper = mount(StatusBadge, { props: { status: loadingListStatusLabel(status) } })
|
|
expect(wrapper.text()).toBe(label)
|
|
expect(wrapper.classes()).toContain(`is-${tone}`)
|
|
wrapper.unmount()
|
|
})
|
|
|
|
it('translates known states and hides unknown backend enums', () => {
|
|
expect(loadingListStatusLabel('EDITING')).toBe('预装柜中')
|
|
expect(loadingListStatusLabel('COMPLETED')).toBe('装柜完成')
|
|
expect(loadingListStatusLabel('NEW_LOADING_STATE')).toBe('未知状态')
|
|
expect(loadingListStatusLabel(null)).toBe('—')
|
|
})
|
|
})
|