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

index d06beff4c8182d5f77acb9de5dd8bd78c897f089..6e108dfd0f279310033119c3e402b3cab12f60d7 100644 (file)
@@ -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 () {