|
1 | 1 | import { shallowMount, createLocalVue } from '@vue/test-utils'
|
2 | 2 | import Header from '@/components/event/Header'
|
3 | 3 | import BootstrapVue from 'bootstrap-vue'
|
| 4 | +import {$routerMocks, deepClone, EVENT_DATA} from '../../utils' |
4 | 5 | import $moment from 'moment'
|
5 |
| -import $http from 'axios' |
6 |
| -import {$routerMocks} from '../../utils' |
| 6 | +import flushPromises from 'flush-promises' |
7 | 7 |
|
8 | 8 | const localVue = createLocalVue()
|
9 | 9 | localVue.use(BootstrapVue)
|
10 | 10 |
|
11 |
| -describe('event/Header.vue', () => { |
12 |
| - |
13 |
| - const wrapper = shallowMount(Header, { |
14 |
| - mocks: Object.assign({ $http, $moment }, $routerMocks), |
| 11 | +function createWrapper() |
| 12 | +{ |
| 13 | + return shallowMount(Header, { |
| 14 | + mocks: Object.assign({ $moment }, $routerMocks), |
15 | 15 | propsData: {
|
16 | 16 | event: {
|
17 | 17 | id: 'ob93enBa'
|
18 | 18 | }
|
19 | 19 | },
|
20 | 20 | localVue
|
21 | 21 | })
|
| 22 | +} |
| 23 | + |
| 24 | +const labelVariants = { |
| 25 | + has_processing: 'processing', |
| 26 | + has_delete: 'deleted', |
| 27 | + has_final: 'final' |
| 28 | +} |
| 29 | + |
| 30 | +describe('event/Header.vue', () => { |
| 31 | + |
| 32 | + describe('Label variant', () => { |
| 33 | + |
| 34 | + const wrapper = createWrapper() |
| 35 | + |
| 36 | + Object.entries(labelVariants).forEach(labelVariant => { |
| 37 | + |
| 38 | + const event = deepClone(EVENT_DATA) |
| 39 | + |
| 40 | + Object.keys(labelVariants).forEach(prop => { |
| 41 | + event[prop] = false |
| 42 | + }) |
| 43 | + |
| 44 | + event[labelVariant[0]] = true |
| 45 | + wrapper.event = event |
| 46 | + |
| 47 | + it(labelVariant[1], async () => { |
| 48 | + flushPromises().then(() => { |
| 49 | + expect(wrapper.vm.label.variant).to.eql(labelVariant[1]) |
| 50 | + }) |
| 51 | + }) |
| 52 | + |
| 53 | + }) |
| 54 | + |
| 55 | + wrapper.destroy() |
22 | 56 |
|
23 |
| - it('Check component Header', () => { |
24 |
| - expect(wrapper.is(Header)).to.eql(true) |
25 | 57 | })
|
26 | 58 |
|
27 | 59 | })
|
0 commit comments