@@ -18,6 +18,22 @@ describe('css-mediaquery', () => {
1818 features : [ ] ,
1919 } ,
2020 ] ) ;
21+
22+ expect ( parseQuery ( 'TV' ) ) . toEqual ( [
23+ {
24+ inverse : false ,
25+ type : 'tv' ,
26+ features : [ ] ,
27+ } ,
28+ ] ) ;
29+
30+ expect ( parseQuery ( 'not speech' ) ) . toEqual ( [
31+ {
32+ inverse : true ,
33+ type : 'speech' ,
34+ features : [ ] ,
35+ } ,
36+ ] ) ;
2137 } ) ;
2238
2339 it ( 'should throw a SyntaxError when a media query is invalid' , ( ) => {
@@ -128,5 +144,35 @@ describe('css-mediaquery', () => {
128144 expect ( matchQuery ( 'not screen and (min-width: 48px)' , { width : 24 } ) ) . toBe ( true ) ;
129145 } ) ;
130146 } ) ;
147+
148+ describe ( 'Unknown and deprecated media types' , ( ) => {
149+ it ( 'should return false for unknown and deprecated media types' , ( ) => {
150+ expect ( matchQuery ( 'tv' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
151+ expect ( matchQuery ( 'speech' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
152+ expect ( matchQuery ( 'handheld' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
153+ expect ( matchQuery ( 'projection' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
154+ expect ( matchQuery ( 'unknown' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
155+ expect ( matchQuery ( 'only tv' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
156+ expect ( matchQuery ( 'tv and (min-width: 100px)' , { type : MediaQueryType . screen , width : 800 } ) ) . toBe ( false ) ;
157+ } ) ;
158+
159+ it ( 'should return true when negating unknown or deprecated media types with `not`' , ( ) => {
160+ expect ( matchQuery ( 'not tv' , { type : MediaQueryType . screen } ) ) . toBe ( true ) ;
161+ expect ( matchQuery ( 'not speech' , { type : MediaQueryType . screen } ) ) . toBe ( true ) ;
162+ expect ( matchQuery ( 'not unknown' , { type : MediaQueryType . screen } ) ) . toBe ( true ) ;
163+ expect ( matchQuery ( 'not tv and (min-width: 100px)' , { type : MediaQueryType . screen , width : 800 } ) ) . toBe ( true ) ;
164+ } ) ;
165+
166+ it ( 'should treat reserved media type keywords as never-matching (`not all`)' , ( ) => {
167+ expect ( matchQuery ( 'not only' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
168+ expect ( matchQuery ( 'not not' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
169+ expect ( matchQuery ( 'not and' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
170+ expect ( matchQuery ( 'not or' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
171+ expect ( matchQuery ( 'not layer' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
172+ expect ( matchQuery ( 'and' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
173+ expect ( matchQuery ( 'or' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
174+ expect ( matchQuery ( 'layer' , { type : MediaQueryType . screen } ) ) . toBe ( false ) ;
175+ } ) ;
176+ } ) ;
131177 } ) ;
132178} ) ;
0 commit comments