Files
admin-web/src/modules/overseas-warehouse/components/FbaAppointmentFields.test.ts
T

28 lines
1.4 KiB
TypeScript

import { mount } from '@vue/test-utils'
import { expect, it } from 'vitest'
import { createAppointmentForm } from '../appointmentForm'
import FbaAppointmentFields from './FbaAppointmentFields.vue'
it('keeps only the planned date for new appointments and allows time fields in other flows', async () => {
const wrapper = mount(FbaAppointmentFields, {
props: { model: createAppointmentForm(), continuous: true, dateOnly: true, timezone: 'America/New_York' },
global: { stubs: {
ElForm: { template: '<form><slot /></form>' },
ElFormItem: { props: ['label'], template: '<label>{{ label }}<slot /></label>' },
ElInput: { template: '<input />' },
ElDatePicker: { template: '<input data-picker />' },
InlineHelp: true,
} },
})
expect(wrapper.text()).toContain('外部约号')
expect(wrapper.text()).toContain('计划送仓日期')
expect(wrapper.findAll('[data-picker]')).toHaveLength(1)
expect(wrapper.text()).not.toMatch(/补充计划时段|计划开始时段|计划结束时段|对方确认开始时间|对方确认结束时间|确认开始时差|确认结束时差|夏令时/)
await wrapper.setProps({ dateOnly: false })
expect(wrapper.text()).toContain('计划开始时段')
expect(wrapper.text()).toContain('计划结束时段')
expect(wrapper.text()).toContain('对方确认开始时间')
expect(wrapper.findAll('[data-picker]')).toHaveLength(5)
wrapper.unmount()
})