-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
cole
committed
Jun 14, 2024
1 parent
eaab6d7
commit 59ed132
Showing
5 changed files
with
63 additions
and
27 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
import { mount } from '@vue/test-utils' | ||
import { describe, expect, it } from 'vitest' | ||
import BaseField from '../index' | ||
import { DatePicker, RangePicker } from 'ant-design-vue' | ||
import { formatDate } from '../utils' | ||
import dayjs from 'dayjs' | ||
|
||
describe('BaseField', () => { | ||
it('render', () => { | ||
const wrapper = mount(() => <BaseField/>) | ||
expect(wrapper.exists()).toBeTruthy() | ||
}) | ||
it('props valueType date', async () => { | ||
const wrapper = mount(BaseField, { | ||
props: { | ||
valueType: 'date' | ||
} | ||
}) | ||
const datePicker = wrapper.findComponent(DatePicker) | ||
expect(datePicker.exists()).toBe(true) | ||
// 只读 | ||
await wrapper.setProps({ mode: 'read' }) | ||
const emptyText = wrapper.props('emptyText') | ||
expect(wrapper.text()).toBe(emptyText) | ||
// text | ||
const text = dayjs() | ||
await wrapper.setProps({ mode: 'read', text: text }) | ||
expect(wrapper.text()).toBe(formatDate(text)) | ||
}) | ||
it('props valueType dateRange', async () => { | ||
const wrapper = mount(BaseField, { | ||
props: { | ||
valueType: 'dateRange' | ||
} | ||
}) | ||
const rangePicker = wrapper.findComponent(RangePicker) | ||
expect(rangePicker.exists()).toBe(true) | ||
// 只读 | ||
await wrapper.setProps({ mode: 'read' }) | ||
const emptyText = wrapper.props('emptyText') | ||
expect(wrapper.text()).toBe(emptyText + '~' + emptyText) | ||
// text | ||
const text = [dayjs(), dayjs()] | ||
await wrapper.setProps({ mode: 'read', text: text }) | ||
expect(wrapper.text()).toBe(formatDate(text[0]) + '~' + formatDate(text[1])) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters