Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 34 additions & 0 deletions components/date-picker/__tests__/date-picker-815.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import { describe, expect, it } from 'vitest';
import { mount } from '@vue/test-utils';
import FDatePicker from '../datePicker.vue';

const CLOSE_ICON_PATH = 'M512 42.667C771.2 42.667 981.333 252.8';

describe('FDatePicker clearable prop (#815)', () => {
it('clearable: true (default) shows the X clear icon when value is set', async () => {
const wrapper = mount(FDatePicker, {
props: {
modelValue: Date.now(),
},
});
const input = wrapper.find('input');
await input.trigger('focus');
await wrapper.vm.$nextTick();
const html = wrapper.html();
expect(html).toContain(CLOSE_ICON_PATH);
});

it('clearable: false hides the X clear icon when value is set', async () => {
const wrapper = mount(FDatePicker, {
props: {
modelValue: Date.now(),
clearable: false,
},
});
const input = wrapper.find('input');
await input.trigger('focus');
await wrapper.vm.$nextTick();
const html = wrapper.html();
expect(html).not.toContain(CLOSE_ICON_PATH);
});
});
2 changes: 1 addition & 1 deletion components/date-picker/datePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ export const datePickerProps = {
},
clearable: {
type: Boolean,
default: false,
default: true,
},
placeholder: {
type: [String, Array] as PropType<string | string[]>,
Expand Down
Loading