@@ -401,3 +401,129 @@ test('transition-duration values are joined when an array', () => {
401
401
expect ( result . warnings ( ) . length ) . toBe ( 0 )
402
402
} )
403
403
} )
404
+
405
+ test ( 'basic screen function calls are expanded' , ( ) => {
406
+ const input = `
407
+ @media screen(sm) {
408
+ .foo {}
409
+ }
410
+ `
411
+
412
+ const output = `
413
+ @media (min-width: 600px) {
414
+ .foo {}
415
+ }
416
+ `
417
+
418
+ return run ( input , {
419
+ theme : { screens : { sm : '600px' } } ,
420
+ } ) . then ( ( result ) => {
421
+ expect ( result . css ) . toMatchCss ( output )
422
+ expect ( result . warnings ( ) . length ) . toBe ( 0 )
423
+ } )
424
+ } )
425
+
426
+ test ( 'screen function supports max-width screens' , ( ) => {
427
+ const input = `
428
+ @media screen(sm) {
429
+ .foo {}
430
+ }
431
+ `
432
+
433
+ const output = `
434
+ @media (max-width: 600px) {
435
+ .foo {}
436
+ }
437
+ `
438
+
439
+ return run ( input , {
440
+ theme : { screens : { sm : { max : '600px' } } } ,
441
+ } ) . then ( ( result ) => {
442
+ expect ( result . css ) . toMatchCss ( output )
443
+ expect ( result . warnings ( ) . length ) . toBe ( 0 )
444
+ } )
445
+ } )
446
+
447
+ test ( 'screen function supports min-width screens' , ( ) => {
448
+ const input = `
449
+ @media screen(sm) {
450
+ .foo {}
451
+ }
452
+ `
453
+
454
+ const output = `
455
+ @media (min-width: 600px) {
456
+ .foo {}
457
+ }
458
+ `
459
+
460
+ return run ( input , {
461
+ theme : { screens : { sm : { min : '600px' } } } ,
462
+ } ) . then ( ( result ) => {
463
+ expect ( result . css ) . toMatchCss ( output )
464
+ expect ( result . warnings ( ) . length ) . toBe ( 0 )
465
+ } )
466
+ } )
467
+
468
+ test ( 'screen function supports min-width and max-width screens' , ( ) => {
469
+ const input = `
470
+ @media screen(sm) {
471
+ .foo {}
472
+ }
473
+ `
474
+
475
+ const output = `
476
+ @media (min-width: 600px) and (max-width: 700px) {
477
+ .foo {}
478
+ }
479
+ `
480
+
481
+ return run ( input , {
482
+ theme : { screens : { sm : { min : '600px' , max : '700px' } } } ,
483
+ } ) . then ( ( result ) => {
484
+ expect ( result . css ) . toMatchCss ( output )
485
+ expect ( result . warnings ( ) . length ) . toBe ( 0 )
486
+ } )
487
+ } )
488
+
489
+ test ( 'screen function supports raw screens' , ( ) => {
490
+ const input = `
491
+ @media screen(mono) {
492
+ .foo {}
493
+ }
494
+ `
495
+
496
+ const output = `
497
+ @media monochrome {
498
+ .foo {}
499
+ }
500
+ `
501
+
502
+ return run ( input , {
503
+ theme : { screens : { mono : { raw : 'monochrome' } } } ,
504
+ } ) . then ( ( result ) => {
505
+ expect ( result . css ) . toMatchCss ( output )
506
+ expect ( result . warnings ( ) . length ) . toBe ( 0 )
507
+ } )
508
+ } )
509
+
510
+ test ( 'screen arguments can be quoted' , ( ) => {
511
+ const input = `
512
+ @media screen('sm') {
513
+ .foo {}
514
+ }
515
+ `
516
+
517
+ const output = `
518
+ @media (min-width: 600px) {
519
+ .foo {}
520
+ }
521
+ `
522
+
523
+ return run ( input , {
524
+ theme : { screens : { sm : '600px' } } ,
525
+ } ) . then ( ( result ) => {
526
+ expect ( result . css ) . toMatchCss ( output )
527
+ expect ( result . warnings ( ) . length ) . toBe ( 0 )
528
+ } )
529
+ } )
0 commit comments