From 96c86397db8ffd9ebe9ae4a553d9ff7e08d1c3e7 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: Tue, 22 Mar 2022 13:40:10 +0300 Subject: [PATCH] Create RadioButton.spec.js --- .../radiobutton/RadioButton.spec.js | 34 +++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 src/components/radiobutton/RadioButton.spec.js diff --git a/src/components/radiobutton/RadioButton.spec.js b/src/components/radiobutton/RadioButton.spec.js new file mode 100644 index 000000000..c85106696 --- /dev/null +++ b/src/components/radiobutton/RadioButton.spec.js @@ -0,0 +1,34 @@ +import { mount } from '@vue/test-utils'; +import RadioButton from './RadioButton.vue'; + +describe('RadioButton.vue', () => { + let wrapper; + + beforeEach(() => { + wrapper = mount(RadioButton, { + props: { + value: 'Tatooine', + modelValue: null + } + }); + }); + + it('shoukd exist', () => { + expect(wrapper.find('.p-radiobutton.p-component').exists()).toBe(true); + expect(wrapper.find('input').attributes().type).toBe('radio'); + }); + + it('should clicked', async () => { + await wrapper.vm.onClick({}); + + expect(wrapper.emitted()['update:modelValue'][0]).toEqual(['Tatooine']); + expect(wrapper.emitted().change[0]).toEqual([{}]); + }); + + it('should checked', async () => { + await wrapper.setProps({ modelValue: 'Tatooine'}); + + expect(wrapper.vm.checked).toBe(true); + expect(wrapper.find('.p-radiobutton').classes()).toContain('p-radiobutton-checked'); + }); +}); \ No newline at end of file