11var assert = require ( 'chai' ) . assert ,
22 doesMQMatch = require ( '../' ) ;
33
4- describe ( '#doesMQMatch() Type ' , function ( ) {
4+ describe ( '#doesMQMatch() media `type` ' , function ( ) {
55 describe ( 'Type' , function ( ) {
66 it ( 'should return true for a correct match' , function ( ) {
77 assert . equal ( doesMQMatch ( 'screen and (color)' , { type : 'screen' , color : 1 } ) , true ) ;
@@ -21,6 +21,27 @@ describe('#doesMQMatch() Type', function () {
2121 } ) ;
2222} ) ;
2323
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+
2445describe ( '#doesMQMatch() Media Features' , function ( ) {
2546 describe ( 'Width' , function ( ) {
2647 it ( 'should return true for a width higher than a min-width' , function ( ) {
@@ -248,7 +269,7 @@ describe('#doesMQMatch() Media Features', function(){
248269} ) ;
249270
250271describe ( '#doesMQMatch() Integration Tests' , function ( ) {
251- describe ( 'Real World Use Cases' , function ( ) {
272+ describe ( 'Real World Use Cases (mostly AND) ' , function ( ) {
252273 it ( 'should return true because of width and type match' , function ( ) {
253274 assert . equal ( doesMQMatch ( 'screen and (min-width: 767px)' , { type : 'screen' , width : 980 } ) , true ) ;
254275 } ) ;
@@ -275,7 +296,7 @@ describe('#doesMQMatch() Integration Tests', function () {
275296
276297 } ) ;
277298
278- describe ( 'Grouped Media Queries' , function ( ) {
299+ describe ( 'Grouped Media Queries (OR) ' , function ( ) {
279300 it ( 'should return true because of color' , function ( ) {
280301 assert . equal ( doesMQMatch ( 'screen and (min-width: 767px), screen and (color)' , { type : 'screen' , color : 1 } ) , true ) ;
281302 } ) ;
0 commit comments