1
1
var assert = require ( 'chai' ) . assert ,
2
2
doesMQMatch = require ( '../' ) ;
3
3
4
- describe ( '#doesMQMatch() Type ' , function ( ) {
4
+ describe ( '#doesMQMatch() media `type` ' , function ( ) {
5
5
describe ( 'Type' , function ( ) {
6
6
it ( 'should return true for a correct match' , function ( ) {
7
7
assert . equal ( doesMQMatch ( 'screen and (color)' , { type : 'screen' , color : 1 } ) , true ) ;
@@ -21,6 +21,27 @@ describe('#doesMQMatch() Type', function () {
21
21
} ) ;
22
22
} ) ;
23
23
24
+
25
+ describe ( '#doesMQMatch() `not` operator' , function ( ) {
26
+ describe ( 'Type' , function ( ) {
27
+ it ( 'should return false when it matches up' , function ( ) {
28
+ assert . equal ( doesMQMatch ( 'not screen and (color)' , { type : 'screen' , color : 1 } ) , false ) ;
29
+ } ) ;
30
+
31
+ it ( 'should not disrupt an OR query' , function ( ) {
32
+ assert . equal ( doesMQMatch ( 'not screen and (color), screen and (min-height: 48em)' , { type : 'screen' , height : 1000 } ) , true ) ;
33
+ } ) ;
34
+
35
+ it ( 'should return false for when type === all' , function ( ) {
36
+ assert . equal ( doesMQMatch ( 'not all and (min-width: 48em)' , { type : 'all' , width : 1000 } ) , false ) ;
37
+ } ) ;
38
+
39
+ it ( 'should return true for inverted value' , function ( ) {
40
+ assert . equal ( doesMQMatch ( 'not screen and (min-width: 48em)' , { width : '24em' } ) , true ) ;
41
+ } ) ;
42
+ } ) ;
43
+ } ) ;
44
+
24
45
describe ( '#doesMQMatch() Media Features' , function ( ) {
25
46
describe ( 'Width' , function ( ) {
26
47
it ( 'should return true for a width higher than a min-width' , function ( ) {
@@ -248,7 +269,7 @@ describe('#doesMQMatch() Media Features', function(){
248
269
} ) ;
249
270
250
271
describe ( '#doesMQMatch() Integration Tests' , function ( ) {
251
- describe ( 'Real World Use Cases' , function ( ) {
272
+ describe ( 'Real World Use Cases (mostly AND) ' , function ( ) {
252
273
it ( 'should return true because of width and type match' , function ( ) {
253
274
assert . equal ( doesMQMatch ( 'screen and (min-width: 767px)' , { type : 'screen' , width : 980 } ) , true ) ;
254
275
} ) ;
@@ -275,7 +296,7 @@ describe('#doesMQMatch() Integration Tests', function () {
275
296
276
297
} ) ;
277
298
278
- describe ( 'Grouped Media Queries' , function ( ) {
299
+ describe ( 'Grouped Media Queries (OR) ' , function ( ) {
279
300
it ( 'should return true because of color' , function ( ) {
280
301
assert . equal ( doesMQMatch ( 'screen and (min-width: 767px), screen and (color)' , { type : 'screen' , color : 1 } ) , true ) ;
281
302
} ) ;
0 commit comments