-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsurvey.test.ts
158 lines (121 loc) · 6.96 KB
/
survey.test.ts
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
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
import { survey } from './survey'
import { describe, it, expect } from 'vitest'
import mockSurvey from '../../../public/api/survey.json'
describe('survey component', () => {
it('should not render if no survey', () => {
survey({ activeFilters: {} })(document.body)
expect(document.body.querySelector('.survey')).toBe(null)
})
it('should render survey', () => {
survey({ survey: mockSurvey, activeFilters: {} })(document.body)
expect(document.body.innerHTML).toMatchInlineSnapshot(`
"
<div class=\\"survey-container\\">
<h2 class=\\"survey-heading\\">Talking about brands</h2>
<div class=\\"question\\">
<h3 class=\\"question-heading\\">Which of these social platforms do you use?</h3>
<div class=\\"answers\\">
<div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 70%\\"></div>
<div class=\\"marker\\" style=\\"width: 70%\\"></div>
<div class=\\"label\\">Facebook</div>
<div class=\\"value\\">70%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 68%\\"></div>
<div class=\\"marker\\" style=\\"width: 68%\\"></div>
<div class=\\"label\\">YouTube</div>
<div class=\\"value\\">68%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 50%\\"></div>
<div class=\\"marker\\" style=\\"width: 50%\\"></div>
<div class=\\"label\\">Instagram</div>
<div class=\\"value\\">50%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 42%\\"></div>
<div class=\\"marker\\" style=\\"width: 42%\\"></div>
<div class=\\"label\\">Twitter</div>
<div class=\\"value\\">42%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 48%\\"></div>
<div class=\\"marker\\" style=\\"width: 48%\\"></div>
<div class=\\"label\\">Snapchat</div>
<div class=\\"value\\">48%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 40%\\"></div>
<div class=\\"marker\\" style=\\"width: 40%\\"></div>
<div class=\\"label\\">Linkedin</div>
<div class=\\"value\\">40%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 0%\\"></div>
<div class=\\"marker\\" style=\\"width: 0%\\"></div>
<div class=\\"label\\">Other</div>
<div class=\\"value\\">0%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 0%\\"></div>
<div class=\\"marker\\" style=\\"width: 0%\\"></div>
<div class=\\"label\\">None</div>
<div class=\\"value\\">0%</div>
</div>
</div>
</div>
</div>
"
`)
})
it('should render survey with active filters', () => {
survey({ survey: mockSurvey, activeFilters: { gender: 'female' } })(document.body)
expect(document.body.innerHTML).toMatchInlineSnapshot(`
"
<div class=\\"survey-container\\">
<h2 class=\\"survey-heading\\">Talking about brands</h2>
<div class=\\"question\\">
<h3 class=\\"question-heading\\">Which of these social platforms do you use?</h3>
<div class=\\"answers\\">
<div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 63.829787234042556%\\"></div>
<div class=\\"marker\\" style=\\"width: 70%\\"></div>
<div class=\\"label\\">Facebook</div>
<div class=\\"value\\">64%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 72.34042553191489%\\"></div>
<div class=\\"marker\\" style=\\"width: 68%\\"></div>
<div class=\\"label\\">YouTube</div>
<div class=\\"value\\">72%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 36.170212765957444%\\"></div>
<div class=\\"marker\\" style=\\"width: 50%\\"></div>
<div class=\\"label\\">Instagram</div>
<div class=\\"value\\">36%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 42.5531914893617%\\"></div>
<div class=\\"marker\\" style=\\"width: 42%\\"></div>
<div class=\\"label\\">Twitter</div>
<div class=\\"value\\">43%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 44.680851063829785%\\"></div>
<div class=\\"marker\\" style=\\"width: 48%\\"></div>
<div class=\\"label\\">Snapchat</div>
<div class=\\"value\\">45%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 38.29787234042553%\\"></div>
<div class=\\"marker\\" style=\\"width: 40%\\"></div>
<div class=\\"label\\">Linkedin</div>
<div class=\\"value\\">38%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 0%\\"></div>
<div class=\\"marker\\" style=\\"width: 0%\\"></div>
<div class=\\"label\\">Other</div>
<div class=\\"value\\">0%</div>
</div> <div class=\\"answer\\">
<div class=\\"track\\" style=\\"width: 0%\\"></div>
<div class=\\"marker\\" style=\\"width: 0%\\"></div>
<div class=\\"label\\">None</div>
<div class=\\"value\\">0%</div>
</div>
</div>
</div>
</div>
"
`)
})
})