Skip to content

Commit

Permalink
test(picker): update
Browse files Browse the repository at this point in the history
  • Loading branch information
subordon committed Aug 3, 2023
1 parent 2c9d1c4 commit ff50d4c
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/packages/__VUE/picker/__tests__/picker.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,14 @@ const multipleColumns = [
]
];

const customColumns = [
{ label: '周一', value: 'Monday' },
{ label: '周二', value: 'Tuesday' },
{ label: '周三', value: 'Wednesday' },
{ label: '周四', value: 'Thursday' },
{ label: '周五', value: 'Friday' }
];

test('first render', async () => {
const wrapper = mount(Picker, {
props: {
Expand Down Expand Up @@ -107,3 +115,26 @@ test('multiple columns render', async () => {
const columnItems = wrapper.findAll('.nut-picker__columnitem');
expect(columnItems.length).toEqual(2);
});

test('custom columns field', async () => {
const wrapper = mount(Picker, {
props: {
visible: true,
columns: customColumns,
fieldNames: {
text: 'label',
value: 'value'
}
}
});
await nextTick();
const columnItems = wrapper.findAll('.nut-picker__columnitem');
expect(columnItems.length).toEqual(1);
wrapper.find('.nut-picker__right').trigger('click');
expect(wrapper.emitted().confirm[0]).toEqual([
{
selectedOptions: [{ label: '周一', value: 'Monday' }],
selectedValue: ['Monday']
}
]);
});

0 comments on commit ff50d4c

Please sign in to comment.