primevue-mirror/components/lib/inputmask/InputMask.spec.js

39 lines
1.1 KiB
JavaScript
Raw Normal View History

2022-09-06 12:03:37 +00:00
import { mount } from '@vue/test-utils';
import InputMask from './InputMask.vue';
describe('InputMask.vue', () => {
it('should exist', async () => {
const wrapper = mount(InputMask, {
props: {
modelValue: null,
mask: '99-999999',
placeholder: '99-999999'
}
});
expect(wrapper.find('.p-inputmask.p-component').exists()).toBe(true);
expect(wrapper.find('.p-inputmask.p-component').attributes().placeholder).toBe('99-999999');
2022-09-14 11:26:01 +00:00
const event = { target: { value: '1' } };
2022-09-06 12:03:37 +00:00
await wrapper.vm.onInput(event);
expect(wrapper.emitted()['update:modelValue'][0]).toEqual(['1']);
});
it('keydown event', async () => {
2022-09-14 11:26:01 +00:00
const wrapper = mount(InputMask, {
2022-09-06 12:03:37 +00:00
props: {
modelValue: null,
mask: '99/99/9999'
}
});
2022-09-14 11:26:01 +00:00
const event = { target: { value: '1' } };
2022-09-06 12:03:37 +00:00
await wrapper.vm.onKeyDown(event);
expect(wrapper.emitted().keydown[0]).toEqual([event]);
});
2022-09-14 11:26:01 +00:00
});