-
-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathAttributionDetailsStep.spec.js
121 lines (102 loc) · 3.39 KB
/
AttributionDetailsStep.spec.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import { createLocalVue, mount } from '@vue/test-utils'
import Buefy from 'buefy'
import Vuex from 'vuex'
import AttributionDetailsStep from '@/components/AttributionDetailsStep'
const localVue = createLocalVue()
localVue.use(Vuex)
localVue.use(Buefy)
describe('AttributionDetailsStep Component Rendering', () => {
let wrapper
beforeEach(() => {
wrapper = mount(AttributionDetailsStep, {
localVue,
mocks: {
$t: key => key,
$store: {
state: {
attributionDetails: {
creatorName: '',
creatorProfileUrl: '',
workTitle: '',
workUrl: ''
}
}
}
}
})
})
afterEach(() => {
wrapper.destroy()
})
it('Component not mounted if status is previous', () => {
wrapper.setProps({ status: 'previous' })
expect(wrapper.find('.step-actions').exists()).toBeFalsy()
})
it('Component not mounted if status is inactive', () => {
wrapper.setProps({ status: 'inactive' })
expect(wrapper.find('.step-actions').exists()).toBeFalsy()
})
it('Component mounted if status is current', () => {
wrapper.setProps({ status: 'current' })
expect(wrapper.element).toMatchSnapshot()
})
})
describe('Store is updated when a user provides input', () => {
let mutations, state, wrapper, store
beforeEach(() => {
mutations = {
setCreatorName: jest.fn(),
setCreatorProfileUrl: jest.fn(),
setWorkTitle: jest.fn(),
setWorkUrl: jest.fn()
}
state = {
attributionDetails: {
creatorName: '',
creatorProfileUrl: '',
workTitle: '',
workUrl: ''
}
}
store = new Vuex.Store({
state,
mutations
})
wrapper = mount(AttributionDetailsStep, {
propsData: {
status: 'current'
},
mocks: {
$t: key => key
},
store,
localVue
})
})
afterEach(() => {
wrapper.destroy()
})
it('Creator Name is updated', async() => {
const input = wrapper.find('input[placeholder="stepper.AD.form.creator-name.placeholder"]')
await input.setValue('Jane Bar')
expect(mutations.setCreatorName).toHaveBeenCalled()
})
// CreatorProfile URL
it('Profile Url is updated', async() => {
const input = wrapper.find('input[placeholder="stepper.AD.form.creator-profile.placeholder"]')
await input.setValue('jane@bar.com')
expect(mutations.setCreatorProfileUrl).toHaveBeenCalled()
})
// Work URL
it('Work Url is updated', async() => {
const input = wrapper.find('input[placeholder="stepper.AD.form.work-url.placeholder"]')
await input.setValue('jane@bar.com/kitty.jpeg')
expect(mutations.setWorkUrl).toHaveBeenCalled()
})
// Work Title
it('Work Title is updated', async() => {
const input = wrapper.find('input[placeholder="stepper.AD.form.work-title.placeholder"]')
await input.setValue('illustrator')
expect(mutations.setWorkTitle).toHaveBeenCalled()
})
})