|
1 |
| -import { mount } from '@vue/test-utils' |
| 1 | +import { createLocalVue, mount } from '@vue/test-utils' |
| 2 | +import Buefy from 'buefy' |
2 | 3 | import FirstStep from '@/components/FirstStep.vue'
|
3 | 4 |
|
4 |
| -describe('FirstStep.vue', () => { |
5 |
| - const wrapper = mount(FirstStep) |
6 |
| - it('Has the main div tag', () => { |
7 |
| - expect(wrapper.contains('.step-content')).toBe(true) |
| 5 | +const localVue = createLocalVue() |
| 6 | + |
| 7 | +localVue.use(Buefy) |
| 8 | + |
| 9 | +describe('FirstStep Component', () => { |
| 10 | + let wrapper |
| 11 | + |
| 12 | + beforeEach(() => { |
| 13 | + wrapper = mount(FirstStep, { |
| 14 | + localVue, |
| 15 | + mocks: { |
| 16 | + $t: key => key |
| 17 | + } |
| 18 | + }) |
8 | 19 | })
|
9 | 20 |
|
10 |
| - it('renders without any errors', () => { |
11 |
| - expect(wrapper.isVueInstance()).toBeTruthy() |
| 21 | + afterEach(() => { |
| 22 | + wrapper.destroy() |
12 | 23 | })
|
13 | 24 |
|
14 |
| - it('Checks if the cardtext function return the correct answer when selected is true', () => { |
| 25 | + it('Mark up is correctly rendered', () => { |
15 | 26 | wrapper.setProps({
|
16 |
| - selected: true |
| 27 | + selected: undefined, |
| 28 | + stepId: 0, |
| 29 | + status: 'current' |
17 | 30 | })
|
18 | 31 |
|
19 |
| - expect(wrapper.vm.cardText).toBe('stepper.FS.selected') |
| 32 | + expect(wrapper.element).toMatchSnapshot() |
20 | 33 | })
|
21 | 34 |
|
22 |
| - it('Checks if the cardtext function return the correct answer when selected is false', () => { |
| 35 | + it('Radio Input value is YES', () => { |
23 | 36 | wrapper.setProps({
|
24 |
| - selected: false |
| 37 | + selected: undefined, |
| 38 | + stepId: 0, |
| 39 | + status: 'current' |
25 | 40 | })
|
26 | 41 |
|
27 |
| - expect(wrapper.vm.cardText).toBe('stepper.FS.not-selected') |
28 |
| - }) |
29 |
| - |
30 |
| - it('Checks if the yesText function returns correct answer ', () => { |
31 |
| - expect(wrapper.vm.yesText).toBe('stepper.FS.selected') |
32 |
| - }) |
| 42 | + const radio = wrapper.findAll('input[type="radio"]').at(0) |
| 43 | + radio.setChecked() |
33 | 44 |
|
34 |
| - it('Checks if the noText function returns correct answer', () => { |
35 |
| - expect(wrapper.vm.noText).toBe('stepper.FS.not-selected') |
| 45 | + expect(wrapper.emitted().change[0]).toEqual(['FS', 0, true]) |
36 | 46 | })
|
37 | 47 |
|
38 |
| - it('Checks if the yesSelected function returns the correct boolean when selected is true', () => { |
| 48 | + it('Radio Input value is NO', () => { |
39 | 49 | wrapper.setProps({
|
40 |
| - selected: true |
| 50 | + selected: undefined, |
| 51 | + stepId: 0, |
| 52 | + status: 'current' |
41 | 53 | })
|
42 |
| - expect(wrapper.vm.yesSelected).toBe('selected') |
43 |
| - }) |
44 | 54 |
|
45 |
| - it('Checks if the yesSelected function returns the correct boolean when selected is false', () => { |
46 |
| - wrapper.setProps({ |
47 |
| - selected: false |
48 |
| - }) |
49 |
| - expect(wrapper.vm.yesSelected).toBe('not-selected') |
| 55 | + const radio = wrapper.findAll('input[type="radio"]').at(1) |
| 56 | + radio.setChecked() |
| 57 | + |
| 58 | + expect(wrapper.emitted().change[0]).toEqual(['FS', 0, false]) |
50 | 59 | })
|
51 | 60 |
|
52 |
| - it('Checks if the get function in radio returns the correct value when selected is undefined', () => { |
| 61 | + it('props:selected false', () => { |
53 | 62 | wrapper.setProps({
|
54 |
| - selected: undefined |
| 63 | + selected: false, |
| 64 | + stepId: 0, |
| 65 | + status: 'current' |
55 | 66 | })
|
56 |
| - expect(wrapper.vm.radio).toBe(undefined) |
57 |
| - }) |
58 | 67 |
|
59 |
| - it('Checks if the get function in radio returns the correct value when selected is yes', () => { |
60 |
| - wrapper.setData({ |
61 |
| - selected: 'yes' |
62 |
| - }) |
63 |
| - expect(wrapper.vm.radio).toBe('yes') |
| 68 | + expect(wrapper.vm.radio).toBe('no') |
| 69 | + expect(wrapper.vm.cardText).toBe('stepper.FS.not-selected') |
64 | 70 | })
|
65 | 71 |
|
66 |
| - it('Checks if the noSelected function returns the correct boolean when selected is true', () => { |
| 72 | + it('props:selected true', () => { |
67 | 73 | wrapper.setProps({
|
68 |
| - selected: true |
| 74 | + selected: true, |
| 75 | + stepId: 0, |
| 76 | + status: 'current' |
69 | 77 | })
|
70 |
| - expect(wrapper.vm.noSelected).toBe('not-selected') |
71 |
| - }) |
72 | 78 |
|
73 |
| - it('Checks if the noSelected function returns the correct boolean when selected is false', () => { |
74 |
| - wrapper.setProps({ |
75 |
| - selected: false |
76 |
| - }) |
77 |
| - expect(wrapper.vm.noSelected).toBe('selected') |
| 79 | + expect(wrapper.vm.radio).toBe('yes') |
| 80 | + expect(wrapper.vm.cardText).toBe('stepper.FS.selected') |
78 | 81 | })
|
79 | 82 | })
|
0 commit comments