@@ -4,29 +4,14 @@ import ComponentWithSlots from '~resources/components/component-with-slots.vue'
4
4
import ComponentAsAClass from '~resources/components/component-as-a-class.vue'
5
5
import {
6
6
describeWithMountingMethods ,
7
- vueVersion ,
8
- isRunningPhantomJS
7
+ vueVersion
9
8
} from '~resources/utils'
10
9
import {
11
10
itSkipIf ,
12
11
itDoNotRunIf
13
12
} from 'conditional-specs'
14
13
15
14
describeWithMountingMethods ( 'options.slots' , ( mountingMethod ) => {
16
- let _window
17
-
18
- beforeEach ( ( ) => {
19
- if ( typeof window !== 'undefined' ) {
20
- _window = window
21
- }
22
- } )
23
-
24
- afterEach ( ( ) => {
25
- if ( typeof window !== 'undefined' && ! window . navigator . userAgent . match ( / C h r o m e / i) ) {
26
- window = _window // eslint-disable-line no-native-reassign
27
- }
28
- } )
29
-
30
15
it ( 'mounts component with default slot if passed component in slot object' , ( ) => {
31
16
const wrapper = mountingMethod ( ComponentWithSlots , { slots : { default : Component } } )
32
17
if ( mountingMethod . name === 'renderToString' ) {
@@ -38,7 +23,6 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
38
23
39
24
itDoNotRunIf (
40
25
mountingMethod . name === 'shallowMount' ||
41
- isRunningPhantomJS ||
42
26
process . env . TEST_ENV === 'node' ,
43
27
'mounts component with default slot if passed component as string in slot object' , ( ) => {
44
28
const CustomComponent = {
@@ -85,7 +69,7 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
85
69
} )
86
70
87
71
itDoNotRunIf (
88
- process . env . TEST_ENV === 'node' || isRunningPhantomJS ,
72
+ process . env . TEST_ENV === 'node' ,
89
73
'mounts component with default slot if passed string in slot object' , ( ) => {
90
74
const wrapper = mountingMethod ( ComponentWithSlots , { slots : { default : '<span />' } } )
91
75
if ( mountingMethod . name === 'renderToString' ) {
@@ -96,7 +80,7 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
96
80
} )
97
81
98
82
itDoNotRunIf (
99
- process . env . TEST_ENV === 'node' || vueVersion < 2.3 || isRunningPhantomJS ,
83
+ process . env . TEST_ENV === 'node' || vueVersion < 2.3 ,
100
84
'works correctly with class component' , ( ) => {
101
85
const wrapper = mountingMethod ( ComponentAsAClass , { slots : { default : '<span />' } } )
102
86
if ( mountingMethod . name === 'renderToString' ) {
@@ -106,27 +90,6 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
106
90
}
107
91
} )
108
92
109
- itDoNotRunIf (
110
- typeof window === 'undefined' || window . navigator . userAgent . match ( / C h r o m e / i) ,
111
- 'works if the UserAgent is PhantomJS when passed Component is in slot object' , ( ) => {
112
- window = { navigator : { userAgent : 'PhantomJS' } } // eslint-disable-line no-native-reassign
113
- const wrapper = mountingMethod ( ComponentWithSlots , { slots : { default : [ Component ] } } )
114
- if ( mountingMethod . name === 'renderToString' ) {
115
- expect ( wrapper ) . contains ( '<div></div>' )
116
- } else {
117
- expect ( wrapper . contains ( Component ) ) . to . equal ( true )
118
- }
119
- } )
120
-
121
- itDoNotRunIf (
122
- typeof window === 'undefined' || window . navigator . userAgent . match ( / C h r o m e / i) ,
123
- 'throws error if the UserAgent is PhantomJS when passed string is in slot object' , ( ) => {
124
- window = { navigator : { userAgent : 'PhantomJS' } } // eslint-disable-line no-native-reassign
125
- const message = '[vue-test-utils]: the slots option does not support strings in PhantomJS. Please use Puppeteer, or pass a component.'
126
- const fn = ( ) => mountingMethod ( ComponentWithSlots , { slots : { default : 'foo' } } )
127
- expect ( fn ) . to . throw ( ) . with . property ( 'message' , message )
128
- } )
129
-
130
93
itDoNotRunIf (
131
94
process . env . TEST_ENV !== 'node' ,
132
95
'throws error passed string is in slot object' , ( ) => {
@@ -135,30 +98,28 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
135
98
expect ( fn ) . to . throw ( ) . with . property ( 'message' , message )
136
99
} )
137
100
138
- itDoNotRunIf (
139
- isRunningPhantomJS ,
140
- 'mounts component with default slot if passed string in slot object' , ( ) => {
141
- if ( mountingMethod . name === 'renderToString' ) {
142
- return
143
- }
144
- const wrapper1 = mountingMethod ( ComponentWithSlots , { slots : { default : 'foo<span>123</span>{{ foo }}' } } )
145
- expect ( wrapper1 . find ( 'main' ) . html ( ) ) . to . equal ( '<main>foo<span>123</span>bar</main>' )
146
- const wrapper2 = mountingMethod ( ComponentWithSlots , { slots : { default : '<p>1</p>{{ foo }}2' } } )
147
- expect ( wrapper2 . find ( 'main' ) . html ( ) ) . to . equal ( '<main><p>1</p>bar2</main>' )
148
- const wrapper3 = mountingMethod ( ComponentWithSlots , { slots : { default : '<p>1</p>{{ foo }}<p>2</p>' } } )
149
- expect ( wrapper3 . find ( 'main' ) . html ( ) ) . to . equal ( '<main><p>1</p>bar<p>2</p></main>' )
150
- const wrapper4 = mountingMethod ( ComponentWithSlots , { slots : { default : '123' } } )
151
- expect ( wrapper4 . find ( 'main' ) . html ( ) ) . to . equal ( '<main>123</main>' )
152
- const wrapper5 = mountingMethod ( ComponentWithSlots , { slots : { default : '1{{ foo }}2' } } )
153
- expect ( wrapper5 . find ( 'main' ) . html ( ) ) . to . equal ( '<main>1bar2</main>' )
154
- wrapper5 . trigger ( 'keydown' )
155
- const wrapper6 = mountingMethod ( ComponentWithSlots , { slots : { default : '<p>1</p><p>2</p>' } } )
156
- expect ( wrapper6 . find ( 'main' ) . html ( ) ) . to . equal ( '<main><p>1</p><p>2</p></main>' )
157
- const wrapper7 = mountingMethod ( ComponentWithSlots , { slots : { default : '1<p>2</p>3' } } )
158
- expect ( wrapper7 . find ( 'main' ) . html ( ) ) . to . equal ( '<main>1<p>2</p>3</main>' )
159
- const wrapper8 = mountingMethod ( ComponentWithSlots , { slots : { default : ' space ' } } )
160
- expect ( wrapper8 . find ( 'main' ) . html ( ) ) . to . equal ( '<main> space </main>' )
161
- } )
101
+ it ( 'mounts component with default slot if passed string in slot object' , ( ) => {
102
+ if ( mountingMethod . name === 'renderToString' ) {
103
+ return
104
+ }
105
+ const wrapper1 = mountingMethod ( ComponentWithSlots , { slots : { default : 'foo<span>123</span>{{ foo }}' } } )
106
+ expect ( wrapper1 . find ( 'main' ) . html ( ) ) . to . equal ( '<main>foo<span>123</span>bar</main>' )
107
+ const wrapper2 = mountingMethod ( ComponentWithSlots , { slots : { default : '<p>1</p>{{ foo }}2' } } )
108
+ expect ( wrapper2 . find ( 'main' ) . html ( ) ) . to . equal ( '<main><p>1</p>bar2</main>' )
109
+ const wrapper3 = mountingMethod ( ComponentWithSlots , { slots : { default : '<p>1</p>{{ foo }}<p>2</p>' } } )
110
+ expect ( wrapper3 . find ( 'main' ) . html ( ) ) . to . equal ( '<main><p>1</p>bar<p>2</p></main>' )
111
+ const wrapper4 = mountingMethod ( ComponentWithSlots , { slots : { default : '123' } } )
112
+ expect ( wrapper4 . find ( 'main' ) . html ( ) ) . to . equal ( '<main>123</main>' )
113
+ const wrapper5 = mountingMethod ( ComponentWithSlots , { slots : { default : '1{{ foo }}2' } } )
114
+ expect ( wrapper5 . find ( 'main' ) . html ( ) ) . to . equal ( '<main>1bar2</main>' )
115
+ wrapper5 . trigger ( 'keydown' )
116
+ const wrapper6 = mountingMethod ( ComponentWithSlots , { slots : { default : '<p>1</p><p>2</p>' } } )
117
+ expect ( wrapper6 . find ( 'main' ) . html ( ) ) . to . equal ( '<main><p>1</p><p>2</p></main>' )
118
+ const wrapper7 = mountingMethod ( ComponentWithSlots , { slots : { default : '1<p>2</p>3' } } )
119
+ expect ( wrapper7 . find ( 'main' ) . html ( ) ) . to . equal ( '<main>1<p>2</p>3</main>' )
120
+ const wrapper8 = mountingMethod ( ComponentWithSlots , { slots : { default : ' space ' } } )
121
+ expect ( wrapper8 . find ( 'main' ) . html ( ) ) . to . equal ( '<main> space </main>' )
122
+ } )
162
123
163
124
itSkipIf ( mountingMethod . name === 'renderToString' ,
164
125
'throws error if passed string in default slot object and vue-template-compiler is undefined' , ( ) => {
@@ -178,7 +139,7 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
178
139
} )
179
140
180
141
itDoNotRunIf (
181
- process . env . TEST_ENV === 'node' || isRunningPhantomJS ,
142
+ process . env . TEST_ENV === 'node' ,
182
143
'mounts component with default slot if passed string in slot array object' , ( ) => {
183
144
const wrapper = mountingMethod ( ComponentWithSlots , { slots : { default : [ '<span />' ] } } )
184
145
if ( mountingMethod . name === 'renderToString' ) {
@@ -189,7 +150,7 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
189
150
} )
190
151
191
152
itDoNotRunIf (
192
- process . env . TEST_ENV === 'node' || isRunningPhantomJS ,
153
+ process . env . TEST_ENV === 'node' ,
193
154
'mounts component with default slot if passed string in slot text array object' , ( ) => {
194
155
const wrapper = mountingMethod ( ComponentWithSlots , { slots : { default : [ '{{ foo }}<span>1</span>' , 'bar' ] } } )
195
156
if ( mountingMethod . name === 'renderToString' ) {
@@ -289,7 +250,7 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
289
250
}
290
251
} )
291
252
292
- itDoNotRunIf ( process . env . TEST_ENV === 'node' || isRunningPhantomJS ,
253
+ itDoNotRunIf ( process . env . TEST_ENV === 'node' ,
293
254
'mounts component with default slot if passed string in slot object' , ( ) => {
294
255
const TestComponent = {
295
256
name : 'component-with-slots' ,
@@ -305,7 +266,7 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
305
266
} )
306
267
307
268
itDoNotRunIf (
308
- process . env . TEST_ENV === 'node' || isRunningPhantomJS ,
269
+ process . env . TEST_ENV === 'node' ,
309
270
'mounts component with named slot if passed string in slot object' , ( ) => {
310
271
const TestComponent = {
311
272
functional : true ,
@@ -320,7 +281,7 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
320
281
} )
321
282
322
283
itDoNotRunIf (
323
- process . env . TEST_ENV === 'node' || isRunningPhantomJS ,
284
+ process . env . TEST_ENV === 'node' ,
324
285
'mounts component with named slot if passed string in slot object in array' , ( ) => {
325
286
const TestComponent = {
326
287
functional : true ,
@@ -335,7 +296,7 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
335
296
} )
336
297
337
298
itDoNotRunIf (
338
- process . env . TEST_ENV === 'node' || isRunningPhantomJS ,
299
+ process . env . TEST_ENV === 'node' ,
339
300
'mounts component with named slot if passed string in slot object in array' , ( ) => {
340
301
const TestComponent = {
341
302
functional : true ,
@@ -350,7 +311,7 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
350
311
} )
351
312
352
313
itDoNotRunIf (
353
- process . env . TEST_ENV === 'node' || isRunningPhantomJS ,
314
+ process . env . TEST_ENV === 'node' ,
354
315
'mounts component with named slot if passed string in slot object in array' , ( ) => {
355
316
const TestComponent = {
356
317
functional : true ,
@@ -431,7 +392,7 @@ describeWithMountingMethods('options.slots', (mountingMethod) => {
431
392
} )
432
393
433
394
itDoNotRunIf (
434
- mountingMethod . name === 'renderToString' || isRunningPhantomJS ,
395
+ mountingMethod . name === 'renderToString' ,
435
396
'does not error when triggering a click in a slot' , ( ) => {
436
397
const Parent = {
437
398
name : 'Parent' ,
0 commit comments