From: Nicolas Coden Date: Sat, 11 Aug 2018 21:02:12 +0000 (+0200) Subject: test: add tests for MediaQuery.upTo() X-Git-Tag: v6.6.0~1^2~2^2~10 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=fe182c64c7e038368a088ad7f99ce77e5af2e060;p=thirdparty%2Ffoundation%2Ffoundation-sites.git test: add tests for MediaQuery.upTo() --- diff --git a/test/javascript/util/mediaQuery.js b/test/javascript/util/mediaQuery.js index 458d81f16..d06beff4c 100644 --- a/test/javascript/util/mediaQuery.js +++ b/test/javascript/util/mediaQuery.js @@ -83,4 +83,35 @@ describe('MediaQuery utils', function () { }); + describe('upTo()', function () { + + it('returns "true" when smaller than the next breakpoint', function () { + $iframe.attr('width', 1023); // just before the "large" breakpoint + (_window.innerWidth); // force the browser to handle the new width synchronously + + plugin.upTo('small').should.be.false; + plugin.upTo('medium').should.be.true; + plugin.upTo('large').should.be.true; + }); + + it('returns "false" when being precisely on the next breakpoint', function () { + $iframe.attr('width', 1200); // just on the "xlarge" breakpoint + (_window.innerWidth); // force the browser to handle the new width synchronously + + plugin.upTo('medium').should.be.false; + plugin.upTo('large').should.be.false; + plugin.upTo('xlarge').should.be.true; + }); + + it('returns "false" when wider than the next breakpoint', function () { + $iframe.attr('width', 1441); // just after the "xxlarge" breakpoint + (_window.innerWidth); // force the browser to handle the new width synchronously + + plugin.upTo('large').should.be.false; + plugin.upTo('xlarge').should.be.false; + plugin.upTo('xxlarge').should.be.true; + }); + + }); + });