Skip to content

Commit 2076b14

Browse files
committed
test: Adjust test cases
1 parent 29a1e01 commit 2076b14

File tree

1 file changed

+18
-8
lines changed

1 file changed

+18
-8
lines changed

tests/unit/components/ActionRow.spec.ts

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,13 @@ import type { ComponentPublicInstance } from 'vue';
1212

1313
const mountActionRow = (
1414
props: Partial<AllPropsType> & { internalModelValue?: InternalModuleValue },
15-
): VueWrapper<ComponentPublicInstance<{ isTimeValid: boolean; isMonthValid: boolean; previewValue: string }>> => {
15+
): VueWrapper<
16+
ComponentPublicInstance<{
17+
isTimeValid: (date: any) => boolean;
18+
isMonthValid: (date: any) => boolean;
19+
previewValue: string;
20+
}>
21+
> => {
1622
return mount(ActionRow, { props }) as any;
1723
};
1824

@@ -30,41 +36,45 @@ describe('ActionRow component', () => {
3036
it('Should not check time', () => {
3137
const wrapper = mountActionRow({ ...props, ignoreTimeValidation: true });
3238

33-
expect(wrapper.vm.isTimeValid).toBe(true);
39+
expect(wrapper.vm.isTimeValid(new Date())).toBe(true);
3440
});
3541

3642
it('Should check if month is within range on maxDate', () => {
43+
const internalModelValue = new Date();
44+
3745
const wrapper = mountActionRow({
3846
...props,
3947
maxDate: addMonths(new Date(), 1),
4048
monthPicker: true,
41-
internalModelValue: new Date(),
49+
internalModelValue,
4250
});
4351

44-
expect(wrapper.vm.isMonthValid).toBe(true);
52+
expect(wrapper.vm.isMonthValid(internalModelValue)).toBe(true);
4553
});
4654

4755
it('Should check if month is within range on minDate', () => {
56+
const internalModelValue = new Date();
4857
const wrapper = mountActionRow({
4958
...props,
5059
minDate: subMonths(new Date(), 1),
5160
monthPicker: true,
52-
internalModelValue: new Date(),
61+
internalModelValue,
5362
});
5463

55-
expect(wrapper.vm.isMonthValid).toBe(true);
64+
expect(wrapper.vm.isMonthValid(internalModelValue)).toBe(true);
5665
});
5766

5867
it('Should check if month is within range on minDate and maxDate', () => {
68+
const internalModelValue = subMonths(new Date(), 3);
5969
const wrapper = mountActionRow({
6070
...props,
6171
minDate: subMonths(new Date(), 1),
6272
maxDate: addMonths(new Date(), 1),
6373
monthPicker: true,
64-
internalModelValue: subMonths(new Date(), 3),
74+
internalModelValue,
6575
});
6676

67-
expect(wrapper.vm.isMonthValid).toBe(false);
77+
expect(wrapper.vm.isMonthValid(internalModelValue)).toBe(false);
6878
});
6979

7080
it('Should format month picker with custom format fn', () => {

0 commit comments

Comments
 (0)