@@ -11,63 +11,75 @@ import url from 'url';
11
11
12
12
const matchCSS = ( doc , regexes ) => {
13
13
if ( process . env . E2E_FILE ) {
14
- const elements = doc . getElementsByTagName ( 'link' ) ;
15
- let href = "" ;
16
- for ( const elem of elements ) {
17
- if ( elem . rel === 'stylesheet' ) {
18
- href = elem . href ;
19
- }
14
+ const elements = doc . getElementsByTagName ( 'link' ) ;
15
+ let href = '' ;
16
+ for ( const elem of elements ) {
17
+ if ( elem . rel === 'stylesheet' ) {
18
+ href = elem . href ;
20
19
}
21
- resourceLoader (
22
- { url : url . parse ( href ) } ,
23
- ( _ , textContent ) => {
24
- for ( const regex of regexes ) {
25
- expect ( textContent ) . to . match ( regex ) ;
26
- }
27
- }
28
- ) ;
29
-
20
+ }
21
+ resourceLoader ( { url : url . parse ( href ) } , ( _ , textContent ) => {
22
+ for ( const regex of regexes ) {
23
+ expect ( textContent ) . to . match ( regex ) ;
24
+ }
25
+ } ) ;
30
26
} else {
31
27
for ( let i = 0 ; i < regexes . length ; ++ i ) {
32
- expect ( doc . getElementsByTagName ( 'style' ) [ i ] . textContent . replace ( / \s / g, '' ) ) . to . match ( regexes [ i ] ) ;
28
+ expect (
29
+ doc . getElementsByTagName ( 'style' ) [ i ] . textContent . replace ( / \s / g, '' )
30
+ ) . to . match ( regexes [ i ] ) ;
33
31
}
34
32
}
35
- }
33
+ } ;
36
34
37
35
describe ( 'Integration' , ( ) => {
38
36
describe ( 'Webpack plugins' , ( ) => {
39
37
it ( 'css inclusion' , async ( ) => {
40
38
const doc = await initDOM ( 'css-inclusion' ) ;
41
- matchCSS ( doc , [ / h t m l \{ / , / # f e a t u r e - c s s - i n c l u s i o n \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
39
+ matchCSS ( doc , [
40
+ / h t m l \{ / ,
41
+ / # f e a t u r e - c s s - i n c l u s i o n \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
42
+ ] ) ;
43
+ doc . defaultView . close ( ) ;
42
44
} ) ;
43
45
44
46
it ( 'css modules inclusion' , async ( ) => {
45
47
const doc = await initDOM ( 'css-modules-inclusion' ) ;
46
- matchCSS ( doc , [ / .+ s t y l e _ c s s M o d u l e s I n c l u s i o n _ _ .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
47
- / .+ a s s e t s _ c s s M o d u l e s I n d e x I n c l u s i o n _ _ .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
48
+ matchCSS ( doc , [
49
+ / .+ s t y l e _ c s s M o d u l e s I n c l u s i o n _ _ .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
50
+ / .+ a s s e t s _ c s s M o d u l e s I n d e x I n c l u s i o n _ _ .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
51
+ ] ) ;
52
+ doc . defaultView . close ( ) ;
48
53
} ) ;
49
54
50
55
it ( 'scss inclusion' , async ( ) => {
51
56
const doc = await initDOM ( 'scss-inclusion' ) ;
52
57
matchCSS ( doc , [ / # f e a t u r e - s c s s - i n c l u s i o n \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
58
+ doc . defaultView . close ( ) ;
53
59
} ) ;
54
60
55
61
it ( 'scss modules inclusion' , async ( ) => {
56
62
const doc = await initDOM ( 'scss-modules-inclusion' ) ;
57
- matchCSS ( doc , [ / .+ s c s s - s t y l e s _ s c s s M o d u l e s I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
58
- / .+ a s s e t s _ s c s s M o d u l e s I n d e x I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
59
-
63
+ matchCSS ( doc , [
64
+ / .+ s c s s - s t y l e s _ s c s s M o d u l e s I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
65
+ / .+ a s s e t s _ s c s s M o d u l e s I n d e x I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
66
+ ] ) ;
67
+ doc . defaultView . close ( ) ;
60
68
} ) ;
61
69
62
70
it ( 'sass inclusion' , async ( ) => {
63
71
const doc = await initDOM ( 'sass-inclusion' ) ;
64
72
matchCSS ( doc , [ / # f e a t u r e - s a s s - i n c l u s i o n \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
73
+ doc . defaultView . close ( ) ;
65
74
} ) ;
66
75
67
76
it ( 'sass modules inclusion' , async ( ) => {
68
77
const doc = await initDOM ( 'sass-modules-inclusion' ) ;
69
- matchCSS ( doc , [ / .+ s a s s - s t y l e s _ s a s s M o d u l e s I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
70
- / .+ a s s e t s _ s a s s M o d u l e s I n d e x I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ] ) ;
78
+ matchCSS ( doc , [
79
+ / .+ s a s s - s t y l e s _ s a s s M o d u l e s I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
80
+ / .+ a s s e t s _ s a s s M o d u l e s I n d e x I n c l u s i o n .+ \{ b a c k g r o u n d : .+ ; c o l o r : .+ } / ,
81
+ ] ) ;
82
+ doc . defaultView . close ( ) ;
71
83
} ) ;
72
84
73
85
it ( 'graphql files inclusion' , async ( ) => {
@@ -78,6 +90,7 @@ describe('Integration', () => {
78
90
expect ( children [ 0 ] . textContent . replace ( / \s / g, '' ) ) . to . equal (
79
91
'{"kind":"Document","definitions":[{"kind":"OperationDefinition","operation":"query","variableDefinitions":[],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[{"kind":"Argument","name":{"kind":"Name","value":"test"},"value":{"kind":"StringValue","value":"test","block":false}}],"directives":[],"selectionSet":{"kind":"SelectionSet","selections":[{"kind":"Field","name":{"kind":"Name","value":"test"},"arguments":[],"directives":[]}]}}]}}],"loc":{"start":0,"end":40,"source":{"body":"{\\ntest(test:\\"test\\"){\\ntest\\n}\\n}\\n","name":"GraphQLrequest","locationOffset":{"line":1,"column":1}}}}'
80
92
) ;
93
+ doc . defaultView . close ( ) ;
81
94
} ) ;
82
95
83
96
it ( 'image inclusion' , async ( ) => {
@@ -86,6 +99,7 @@ describe('Integration', () => {
86
99
expect ( doc . getElementById ( 'feature-image-inclusion' ) . src ) . to . match (
87
100
/ ^ d a t a : i m a g e \/ j p e g ; b a s e 6 4 .+ = = $ /
88
101
) ;
102
+ doc . defaultView . close ( ) ;
89
103
} ) ;
90
104
91
105
it ( 'no ext inclusion' , async ( ) => {
@@ -94,6 +108,7 @@ describe('Integration', () => {
94
108
expect ( doc . getElementById ( 'feature-no-ext-inclusion' ) . href ) . to . match (
95
109
/ \/ s t a t i c \/ m e d i a \/ a F i l e W i t h o u t E x t \. [ a - f 0 - 9 ] { 8 } \. b i n $ /
96
110
) ;
111
+ doc . defaultView . close ( ) ;
97
112
} ) ;
98
113
99
114
it ( 'json inclusion' , async ( ) => {
@@ -102,6 +117,7 @@ describe('Integration', () => {
102
117
expect ( doc . getElementById ( 'feature-json-inclusion' ) . textContent ) . to . equal (
103
118
'This is an abstract.'
104
119
) ;
120
+ doc . defaultView . close ( ) ;
105
121
} ) ;
106
122
107
123
it ( 'linked modules' , async ( ) => {
@@ -110,13 +126,15 @@ describe('Integration', () => {
110
126
expect ( doc . getElementById ( 'feature-linked-modules' ) . textContent ) . to . equal (
111
127
'2.0.0'
112
128
) ;
129
+ doc . defaultView . close ( ) ;
113
130
} ) ;
114
131
115
132
it ( 'svg inclusion' , async ( ) => {
116
133
const doc = await initDOM ( 'svg-inclusion' ) ;
117
134
expect ( doc . getElementById ( 'feature-svg-inclusion' ) . src ) . to . match (
118
135
/ \/ s t a t i c \/ m e d i a \/ l o g o \. .+ \. s v g $ /
119
136
) ;
137
+ doc . defaultView . close ( ) ;
120
138
} ) ;
121
139
122
140
it ( 'svg component' , async ( ) => {
@@ -125,11 +143,13 @@ describe('Integration', () => {
125
143
expect ( doc . getElementById ( 'feature-svg-component' ) . textContent ) . to . equal (
126
144
''
127
145
) ;
146
+ doc . defaultView . close ( ) ;
128
147
} ) ;
129
148
130
149
it ( 'svg in css' , async ( ) => {
131
150
const doc = await initDOM ( 'svg-in-css' ) ;
132
151
matchCSS ( doc , [ / \/ s t a t i c \/ m e d i a \/ l o g o \. .+ \. s v g / ] ) ;
152
+ doc . defaultView . close ( ) ;
133
153
} ) ;
134
154
135
155
it ( 'unknown ext inclusion' , async ( ) => {
@@ -138,6 +158,7 @@ describe('Integration', () => {
138
158
expect ( doc . getElementById ( 'feature-unknown-ext-inclusion' ) . href ) . to . match (
139
159
/ \/ s t a t i c \/ m e d i a \/ a F i l e W i t h E x t \. [ a - f 0 - 9 ] { 8 } \. u n k n o w n $ /
140
160
) ;
161
+ doc . defaultView . close ( ) ;
141
162
} ) ;
142
163
} ) ;
143
164
} ) ;
0 commit comments