|
| 1 | +import { createLocalVue, mount } from '@vue/test-utils' |
| 2 | +import Buefy from 'buefy' |
| 3 | +import Vuex from 'vuex' |
| 4 | +import DropdownStep from '@/components/DropdownStep' |
| 5 | + |
| 6 | +const localVue = createLocalVue() |
| 7 | + |
| 8 | +localVue.use(Vuex) |
| 9 | +localVue.use(Buefy) |
| 10 | + |
| 11 | +describe('DropdownStep', () => { |
| 12 | + let wrapper, store, getters, mutations |
| 13 | + |
| 14 | + beforeEach(() => { |
| 15 | + getters = { |
| 16 | + fullName: jest.fn().mockReturnValue(undefined), |
| 17 | + shortName: jest.fn().mockReturnValue(undefined) |
| 18 | + } |
| 19 | + |
| 20 | + mutations = { |
| 21 | + updateAttributesFromShort: jest.fn() |
| 22 | + } |
| 23 | + |
| 24 | + store = new Vuex.Store({ |
| 25 | + getters, |
| 26 | + mutations |
| 27 | + }) |
| 28 | + |
| 29 | + wrapper = mount(DropdownStep, { |
| 30 | + localVue, |
| 31 | + propsData: { |
| 32 | + stepId: 5, |
| 33 | + status: 'current' |
| 34 | + }, |
| 35 | + mocks: { |
| 36 | + $t: key => key |
| 37 | + }, |
| 38 | + store |
| 39 | + }) |
| 40 | + }) |
| 41 | + |
| 42 | + afterEach(() => { |
| 43 | + wrapper.destroy() |
| 44 | + }) |
| 45 | + |
| 46 | + it('Checks conditional rendering of markup: status is current', () => { |
| 47 | + expect(wrapper.find('.step-actions').exists()).toBeTruthy() |
| 48 | + }) |
| 49 | + |
| 50 | + it('Checks methods: updateSelected', () => { |
| 51 | + const options = wrapper.find('select').findAll('option') |
| 52 | + |
| 53 | + options.at(1).setSelected() |
| 54 | + |
| 55 | + expect(wrapper.emitted().input[0]).toStrictEqual(['DD', 5, true]) |
| 56 | + }) |
| 57 | +}) |
| 58 | + |
| 59 | +describe('DropdownStep', () => { |
| 60 | + let wrapper, store, getters |
| 61 | + |
| 62 | + beforeEach(() => { |
| 63 | + getters = { |
| 64 | + fullName: jest.fn().mockReturnValue('CC 1.0 Universal') |
| 65 | + } |
| 66 | + |
| 67 | + store = new Vuex.Store({ |
| 68 | + getters |
| 69 | + }) |
| 70 | + |
| 71 | + wrapper = mount(DropdownStep, { |
| 72 | + localVue, |
| 73 | + mocks: { |
| 74 | + $t: key => key |
| 75 | + }, |
| 76 | + store |
| 77 | + }) |
| 78 | + }) |
| 79 | + |
| 80 | + afterEach(() => { |
| 81 | + wrapper.destroy() |
| 82 | + }) |
| 83 | + |
| 84 | + it('Checks conditional rendering of markup: status is inactive', () => { |
| 85 | + wrapper.setProps({ |
| 86 | + stepId: 5, |
| 87 | + status: 'inactive' |
| 88 | + }) |
| 89 | + expect(wrapper.find('.step-description').exists()).toBeFalsy() |
| 90 | + expect(wrapper.find('.step-actions').exists()).toBeFalsy() |
| 91 | + }) |
| 92 | + |
| 93 | + it('Checks getters and computed property cardText && Checks conditional rendering of markup', () => { |
| 94 | + wrapper.setProps({ |
| 95 | + stepId: 5, |
| 96 | + status: 'previous' |
| 97 | + }) |
| 98 | + |
| 99 | + expect(wrapper.find('.step-description').exists()).toBeTruthy() |
| 100 | + expect(wrapper.vm.fullName).toBe('CC 1.0 Universal') |
| 101 | + expect(wrapper.vm.cardText).toBe('CC 1.0 Universal') |
| 102 | + expect(wrapper.find('.step-description').text()).toBe('CC 1.0 Universal') |
| 103 | + }) |
| 104 | +}) |
0 commit comments