2
2
* @jest -environment jsdom
3
3
*/
4
4
5
- /* eslint-disable func-names */
5
+ /* eslint-disable func-names, no-undefined */
6
6
7
7
const api = require ( "../../src/runtime/api" ) ;
8
8
const noSourceMaps = require ( "../../src/runtime/noSourceMaps" ) ;
@@ -30,45 +30,140 @@ describe("api", () => {
30
30
it ( "should toString a single module" , ( ) => {
31
31
const m = api ( noSourceMaps ) ;
32
32
33
- m . push ( [ 1 , "body { a: 1; }" , "" ] ) ;
33
+ m . push ( [ 1 , "body { a: 1; }" ] ) ;
34
34
35
35
expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
36
36
} ) ;
37
37
38
38
it ( "should toString multiple modules" , ( ) => {
39
39
const m = api ( noSourceMaps ) ;
40
40
41
- m . push ( [ 2 , "body { b: 2; }" , "" ] ) ;
42
- m . push ( [ 1 , "body { a: 1; }" , "" ] ) ;
41
+ m . push ( [ 2 , "body { b: 2; }" ] ) ;
42
+ m . push ( [ 1 , "body { a: 1; }" ] ) ;
43
43
44
44
expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
45
45
} ) ;
46
46
47
- it ( "should toString with media query" , ( ) => {
47
+ it ( "should toString with media query list " , ( ) => {
48
48
const m = api ( noSourceMaps ) ;
49
49
50
- const m1 = [ 1 , "body { a: 1; }" , "screen" ] ;
51
- const m2 = [ 2 , "body { b: 2; }" , "" ] ;
52
- const m3 = [ 3 , "body { c: 3; }" , "" ] ;
53
- const m4 = [ 4 , "body { d: 4; }" , "" ] ;
50
+ const m1 = [ 1 , "body { a: 1; }" , "(min-width: 900px)" ] ;
51
+ const m2 = [ 2 , "body { b: 2; }" , undefined ] ;
52
+ const m3 = [ 3 , "body { c: 3; }" , undefined ] ;
53
+ const m4 = [ 4 , "body { d: 4; }" , undefined ] ;
54
+ const m5 = [ 5 , "body { e: 5; }" , "screen and (min-width: 900px)" ] ;
54
55
55
- m . i ( [ m2 , m3 ] , "" ) ;
56
- m . i ( [ m2 ] , "" ) ;
56
+ m . i ( [ m2 , m3 ] ) ;
57
+ m . i ( [ m2 ] ) ;
57
58
m . i ( [ m2 , m4 ] , "print" ) ;
58
59
m . push ( m1 ) ;
60
+ m . i ( [ m1 ] , "screen" ) ;
61
+ m . i ( [ m5 ] ) ;
62
+
63
+ expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
64
+ } ) ;
65
+
66
+ it ( "should toString with supports" , ( ) => {
67
+ const m = api ( noSourceMaps ) ;
68
+
69
+ const m1 = [ 1 , "body { a: 1; }" , undefined , undefined , "display: flex" ] ;
70
+ const m2 = [ 2 , "body { b: 2; }" , undefined ] ;
71
+ const m3 = [ 3 , "body { c: 3; }" , undefined ] ;
72
+ const m4 = [ 4 , "body { d: 4; }" , undefined ] ;
73
+ const m5 = [ 5 , "body { e: 5; }" , undefined , undefined , "display: grid" ] ;
74
+
75
+ m . i ( [ m2 , m3 ] ) ;
76
+ m . i ( [ m2 ] ) ;
77
+ m . i ( [ m2 , m4 ] , undefined , false , "display: flex" ) ;
78
+ m . push ( m1 ) ;
79
+ m . i ( [ m1 , m5 ] , undefined , false , "display: block" ) ;
80
+ m . i ( [ m5 ] ) ;
81
+
82
+ expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
83
+ } ) ;
84
+
85
+ it ( "should toString with layer" , ( ) => {
86
+ const m = api ( noSourceMaps ) ;
87
+
88
+ const m1 = [
89
+ 1 ,
90
+ "body { a: 1; }" ,
91
+ undefined ,
92
+ undefined ,
93
+ undefined ,
94
+ "default" ,
95
+ ] ;
96
+ const m2 = [ 2 , "body { b: 2; }" , undefined ] ;
97
+ const m3 = [ 3 , "body { c: 3; }" , undefined ] ;
98
+ const m4 = [ 4 , "body { d: 4; }" , undefined ] ;
99
+ const m5 = [ 5 , "body { e: 5; }" , undefined , undefined , undefined , "" ] ;
100
+ const m6 = [
101
+ 5 ,
102
+ "body { f: 6; }" ,
103
+ undefined ,
104
+ undefined ,
105
+ undefined ,
106
+ undefined ,
107
+ ] ;
108
+
109
+ m . i ( [ m2 , m3 ] , undefined ) ;
110
+ m . i ( [ m2 ] , undefined ) ;
111
+ m . i ( [ m2 , m4 ] , "print" ) ;
112
+ m . push ( m1 ) ;
113
+ m . i ( [ m5 ] ) ;
114
+ m . i ( [ m1 , m5 ] , undefined , undefined , undefined , "framework" ) ;
115
+ m . i ( [ m6 ] , undefined , undefined , undefined , "framework" ) ;
116
+
117
+ expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
118
+ } ) ;
119
+
120
+ it ( "should toString with media query list, layer and supports" , ( ) => {
121
+ const m = api ( noSourceMaps ) ;
122
+
123
+ const m1 = [
124
+ 1 ,
125
+ "body { a: 1; }" ,
126
+ "screen" ,
127
+ undefined ,
128
+ "display: grid" ,
129
+ "default" ,
130
+ ] ;
131
+ const m2 = [ 2 , "body { b: 2; }" , undefined ] ;
132
+ const m3 = [ 3 , "body { c: 3; }" , undefined ] ;
133
+ const m4 = [ 4 , "body { d: 4; }" , undefined ] ;
134
+ const m5 = [
135
+ 5 ,
136
+ "body { a: 1; }" ,
137
+ "screen" ,
138
+ undefined ,
139
+ "display: grid" ,
140
+ "default" ,
141
+ ] ;
142
+
143
+ m . i ( [ m2 , m3 ] , undefined ) ;
144
+ m . i ( [ m2 ] , undefined ) ;
145
+ m . i ( [ m2 , m4 ] , "print" ) ;
146
+ m . push ( m1 ) ;
147
+ m . i (
148
+ [ m5 ] ,
149
+ "screen and (mix-width: 100px)" ,
150
+ false ,
151
+ "display: block" ,
152
+ "framework"
153
+ ) ;
59
154
60
155
expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
61
156
} ) ;
62
157
63
158
it ( "should import modules" , ( ) => {
64
159
const m = api ( noSourceMaps ) ;
65
160
const m1 = [ 1 , "body { a: 1; }" , "(orientation:landscape)" ] ;
66
- const m2 = [ 2 , "body { b: 2; }" , "" ] ;
67
- const m3 = [ 3 , "body { c: 3; }" , "" ] ;
68
- const m4 = [ 4 , "body { d: 4; }" , "" ] ;
161
+ const m2 = [ 2 , "body { b: 2; }" , undefined ] ;
162
+ const m3 = [ 3 , "body { c: 3; }" , undefined ] ;
163
+ const m4 = [ 4 , "body { d: 4; }" , undefined ] ;
69
164
70
- m . i ( [ m2 , m3 ] , "" ) ;
71
- m . i ( [ m2 ] , "" ) ;
165
+ m . i ( [ m2 , m3 ] , undefined ) ;
166
+ m . i ( [ m2 ] , undefined ) ;
72
167
m . i ( [ m2 , m4 ] , "print" ) ;
73
168
m . i ( [ m1 ] , "screen" ) ;
74
169
m . push ( m1 ) ;
@@ -79,12 +174,12 @@ describe("api", () => {
79
174
it ( "should import named modules" , ( ) => {
80
175
const m = api ( noSourceMaps ) ;
81
176
const m1 = [ "./module1" , "body { a: 1; }" , "screen" ] ;
82
- const m2 = [ "./module2" , "body { b: 2; }" , "" ] ;
83
- const m3 = [ "./module3" , "body { c: 3; }" , "" ] ;
84
- const m4 = [ "./module4" , "body { d: 4; }" , "" ] ;
177
+ const m2 = [ "./module2" , "body { b: 2; }" , undefined ] ;
178
+ const m3 = [ "./module3" , "body { c: 3; }" , undefined ] ;
179
+ const m4 = [ "./module4" , "body { d: 4; }" , undefined ] ;
85
180
86
- m . i ( [ m2 , m3 ] , "" ) ;
87
- m . i ( [ m2 ] , "" ) ;
181
+ m . i ( [ m2 , m3 ] , undefined ) ;
182
+ m . i ( [ m2 ] , undefined ) ;
88
183
m . i ( [ m2 , m4 ] , "print" ) ;
89
184
m . push ( m1 ) ;
90
185
@@ -97,7 +192,7 @@ describe("api", () => {
97
192
m . push ( [
98
193
1 ,
99
194
"body { a: 1; }" ,
100
- "" ,
195
+ undefined ,
101
196
{
102
197
file : "test.scss" ,
103
198
sources : [ "./path/to/test.scss" ] ,
@@ -134,7 +229,7 @@ describe("api", () => {
134
229
m . push ( [
135
230
1 ,
136
231
"body { a: 1; }" ,
137
- "" ,
232
+ undefined ,
138
233
{
139
234
file : "test.scss" ,
140
235
sources : [ "./path/to/test.scss" ] ,
@@ -184,4 +279,3 @@ describe("api", () => {
184
279
expect ( m . toString ( ) ) . toMatchSnapshot ( ) ;
185
280
} ) ;
186
281
} ) ;
187
- /* eslint-enable func-names */
0 commit comments