From d77b4b1f4a2449ed475db87db2030d62062815b8 Mon Sep 17 00:00:00 2001 From: Nicolas Coden Date: Sun, 12 Aug 2018 00:06:03 +0200 Subject: [PATCH] test: add tests for "MediaQuery.only()" --- test/javascript/util/mediaQuery.js | 31 ++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/javascript/util/mediaQuery.js b/test/javascript/util/mediaQuery.js index d06beff4c..6e108dfd0 100644 --- a/test/javascript/util/mediaQuery.js +++ b/test/javascript/util/mediaQuery.js @@ -83,6 +83,37 @@ describe('MediaQuery utils', function () { }); + describe('only()', function () { + + it('returns "false" when smaller than the given breakpoint', function () { + $iframe.attr('width', 639); // just before the "medium" breakpoint + (_window.innerWidth); // force the browser to handle the new width synchronously + + plugin.only('small').should.be.true; + plugin.only('medium').should.be.false; + plugin.only('large').should.be.false; + }); + + it('returns "true" when within the given breakpoint', function () { + $iframe.attr('width', 832); // within the "medium" breakpoint + (_window.innerWidth); // force the browser to handle the new width synchronously + + plugin.only('small').should.be.false; + plugin.only('medium').should.be.true; + plugin.only('large').should.be.false; + }); + + it('returns "false" when wider than given breakpoint', function () { + $iframe.attr('width', 1024); // just after the "medium" breakpoint + (_window.innerWidth); // force the browser to handle the new width synchronously + + plugin.only('small').should.be.false; + plugin.only('medium').should.be.false; + plugin.only('large').should.be.true; + }); + + }); + describe('upTo()', function () { it('returns "true" when smaller than the next breakpoint', function () { -- 2.47.2