From b385475d84ee748b6de821db01a1a964b3d318e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tu=C4=9F=C3=A7e=20K=C3=BC=C3=A7=C3=BCko=C4=9Flu?= Date: Wed, 16 Mar 2022 16:15:49 +0300 Subject: [PATCH] Create InputMask.spec.js --- src/components/inputmask/InputMask.spec.js | 38 ++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 src/components/inputmask/InputMask.spec.js diff --git a/src/components/inputmask/InputMask.spec.js b/src/components/inputmask/InputMask.spec.js new file mode 100644 index 000000000..9ff06f86b --- /dev/null +++ b/src/components/inputmask/InputMask.spec.js @@ -0,0 +1,38 @@ +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'); + + const event = {'target': { 'value': '1' }}; + + await wrapper.vm.onInput(event); + + expect(wrapper.emitted()['update:modelValue'][0]).toEqual(['1']); + }); + + it('keydown event', async () => { + const wrapper = mount(InputMask, { + props: { + modelValue: null, + mask: '99/99/9999' + } + }); + + const event = {'target': { 'value': '1' }}; + + await wrapper.vm.onKeyDown(event); + + expect(wrapper.emitted().keydown[0]).toEqual([event]); + }); +}); \ No newline at end of file