@@ -8,12 +8,12 @@ describe('css-selector', () => {
8
8
sel . match ( < any > {
9
9
cssType : 'button' ,
10
10
testAttr : true ,
11
- } )
11
+ } ) ,
12
12
) . toBeTruthy ( ) ;
13
13
expect (
14
14
sel . match ( < any > {
15
15
cssType : 'button' ,
16
- } )
16
+ } ) ,
17
17
) . toBeFalsy ( ) ;
18
18
} ) ;
19
19
@@ -119,7 +119,7 @@ describe('css-selector', () => {
119
119
}
120
120
} ) ;
121
121
122
- it ( 'direct parent combinator' , ( ) => {
122
+ it ( 'direct child combinator' , ( ) => {
123
123
const rule = createOne ( `listview > item:selected { color: red; }` ) ;
124
124
expect (
125
125
rule . selectors [ 0 ] . match ( {
@@ -128,7 +128,7 @@ describe('css-selector', () => {
128
128
parent : {
129
129
cssType : 'listview' ,
130
130
} ,
131
- } )
131
+ } ) ,
132
132
) . toBe ( true ) ;
133
133
expect (
134
134
rule . selectors [ 0 ] . match ( {
@@ -140,11 +140,11 @@ describe('css-selector', () => {
140
140
cssType : 'listview' ,
141
141
} ,
142
142
} ,
143
- } )
143
+ } ) ,
144
144
) . toBe ( false ) ;
145
145
} ) ;
146
146
147
- it ( 'ancestor combinator' , ( ) => {
147
+ it ( 'descendant combinator' , ( ) => {
148
148
const rule = createOne ( `listview item:selected { color: red; }` ) ;
149
149
expect (
150
150
rule . selectors [ 0 ] . match ( {
@@ -153,7 +153,7 @@ describe('css-selector', () => {
153
153
parent : {
154
154
cssType : 'listview' ,
155
155
} ,
156
- } )
156
+ } ) ,
157
157
) . toBe ( true ) ;
158
158
expect (
159
159
rule . selectors [ 0 ] . match ( {
@@ -165,7 +165,7 @@ describe('css-selector', () => {
165
165
cssType : 'listview' ,
166
166
} ,
167
167
} ,
168
- } )
168
+ } ) ,
169
169
) . toBe ( true ) ;
170
170
expect (
171
171
rule . selectors [ 0 ] . match ( {
@@ -177,7 +177,7 @@ describe('css-selector', () => {
177
177
cssType : 'page' ,
178
178
} ,
179
179
} ,
180
- } )
180
+ } ) ,
181
181
) . toBe ( false ) ;
182
182
} ) ;
183
183
@@ -202,6 +202,79 @@ describe('css-selector', () => {
202
202
expect ( sel . match ( child ) ) . toBe ( true ) ;
203
203
} ) ;
204
204
205
+ it ( ':not() pseudo-class' , ( ) => {
206
+ const rule = createOne ( `listview :not(item:selected) { color: red; }` ) ;
207
+ expect (
208
+ rule . selectors [ 0 ] . match ( {
209
+ cssType : 'item' ,
210
+ cssPseudoClasses : new Set ( [ 'selected' ] ) ,
211
+ parent : {
212
+ cssType : 'listview' ,
213
+ } ,
214
+ } ) ,
215
+ ) . toBe ( false ) ;
216
+ expect (
217
+ rule . selectors [ 0 ] . match ( {
218
+ cssType : 'item' ,
219
+ parent : {
220
+ cssType : 'listview' ,
221
+ } ,
222
+ } ) ,
223
+ ) . toBe ( true ) ;
224
+ expect (
225
+ rule . selectors [ 0 ] . match ( {
226
+ cssType : 'label' ,
227
+ parent : {
228
+ cssType : 'listview' ,
229
+ } ,
230
+ } ) ,
231
+ ) . toBe ( true ) ;
232
+ } ) ;
233
+
234
+ it ( ':is() pseudo-class' , ( ) => {
235
+ const rule = createOne ( `listview :is(item:selected) { color: red; }` ) ;
236
+ expect (
237
+ rule . selectors [ 0 ] . match ( {
238
+ cssType : 'item' ,
239
+ cssPseudoClasses : new Set ( [ 'selected' ] ) ,
240
+ parent : {
241
+ cssType : 'listview' ,
242
+ } ,
243
+ } ) ,
244
+ ) . toBe ( true ) ;
245
+ expect (
246
+ rule . selectors [ 0 ] . match ( {
247
+ cssType : 'item' ,
248
+ parent : {
249
+ cssType : 'listview' ,
250
+ } ,
251
+ } ) ,
252
+ ) . toBe ( false ) ;
253
+ } ) ;
254
+
255
+ it ( ':where() pseudo-class' , ( ) => {
256
+ const rule = createOne ( `listview :is(item:selected) { color: red; }` ) ;
257
+ expect (
258
+ rule . selectors [ 0 ] . match ( {
259
+ cssType : 'item' ,
260
+ cssPseudoClasses : new Set ( [ 'selected' ] ) ,
261
+ parent : {
262
+ cssType : 'listview' ,
263
+ } ,
264
+ } ) ,
265
+ ) . toBe ( true ) ;
266
+ expect (
267
+ rule . selectors [ 0 ] . match ( {
268
+ cssType : 'item' ,
269
+ parent : {
270
+ cssType : 'listview' ,
271
+ } ,
272
+ } ) ,
273
+ ) . toBe ( false ) ;
274
+ // TODO: Re-add this when decorators actually work with ts-jest
275
+ //expect(rule.selectors[0].specificity).toEqual(0);
276
+ } ) ;
277
+
205
278
function toString ( ) {
206
279
return this . cssType ;
207
280
}
0 commit comments