]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
test: add tests for MediaQuery.upTo()
authorNicolas Coden <nicolas@ncoden.fr>
Sat, 11 Aug 2018 21:02:12 +0000 (23:02 +0200)
committerDaniel Ruf <mac1@daniel-ruf.de>
Sun, 17 Nov 2019 15:49:44 +0000 (16:49 +0100)
test/javascript/util/mediaQuery.js

index 458d81f16a7f1277beaf954ae5b236461cee703d..d06beff4c8182d5f77acb9de5dd8bd78c897f089 100644 (file)
@@ -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;
+    });
+
+  });
+
 });