test.js 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. var should = require('should');
  2. var json2mq = require('../');
  3. describe('json2mq', function () {
  4. it('should return query string for media type', function () {
  5. json2mq({screen: true}).should.equal('screen');
  6. });
  7. it('should return query string for media type with not', function () {
  8. json2mq({handheld: false}).should.equal('not handheld');
  9. });
  10. it('should return query string for media features', function () {
  11. json2mq({minWidth: 100, maxWidth: 200}).should.equal('(min-width: 100px) and (max-width: 200px)');
  12. });
  13. it('should return query string for media type and media features', function () {
  14. json2mq({screen: true, minWidth: 100, maxWidth: 200}).should.equal('screen and (min-width: 100px) and (max-width: 200px)');
  15. });
  16. it('should add px unit to dimension features', function () {
  17. json2mq({minWidth: 100, aspectRatio: "3/4"}).should.equal('(min-width: 100px) and (aspect-ratio: 3/4)');
  18. });
  19. it('should accept other units for dimension features if passed as string', function () {
  20. json2mq({minWidth: '10em', aspectRatio: "3/4"}).should.equal('(min-width: 10em) and (aspect-ratio: 3/4)');
  21. });
  22. it('should return comma seperated query string for multiple media queries', function () {
  23. json2mq([
  24. {minWidth: 100},
  25. {handheld: true, orientation: 'landscape'}
  26. ]).should.equal('(min-width: 100px), handheld and (orientation: landscape)');
  27. });
  28. it('should only return feature if its value is true', function () {
  29. json2mq({all: true, monochrome: true}).should.equal('all and monochrome');
  30. });
  31. });