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

index 883bb8f30a2c004454cb6bdf0abef2f938b7c18f..458d81f16a7f1277beaf954ae5b236461cee703d 100644 (file)
@@ -52,5 +52,35 @@ describe('MediaQuery utils', function () {
     $iframe.remove();
   });
 
+  describe('atLeast()', 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.atLeast('small').should.be.true;
+      plugin.atLeast('medium').should.be.false;
+      plugin.atLeast('large').should.be.false;
+    });
+
+    it('returns "true" when being precisely on the given breakpoint', function () {
+      $iframe.attr('width', 1024); // just on the "large" breakpoint
+      (_window.innerWidth); // force the browser to handle the new width synchronously
+
+      plugin.atLeast('medium').should.be.true;
+      plugin.atLeast('large').should.be.true;
+      plugin.atLeast('xlarge').should.be.false;
+    });
+
+    it('returns "true" when wider than the given breakpoint', function () {
+      $iframe.attr('width', 1201); // just after the "xlarge" breakpoint
+      (_window.innerWidth); // force the browser to handle the new width synchronously
+
+      plugin.atLeast('large').should.be.true;
+      plugin.atLeast('xlarge').should.be.true;
+      plugin.atLeast('xxlarge').should.be.false;
+    });
+
+  });
 
 });