]> git.ipfire.org Git - thirdparty/foundation/foundation-sites.git/commitdiff
start of Box unit tests 9933/head
authorKristofer Krause <kris.krause@gmail.com>
Thu, 6 Apr 2017 21:13:01 +0000 (17:13 -0400)
committerKristofer Krause <kris.krause@gmail.com>
Thu, 6 Apr 2017 21:13:01 +0000 (17:13 -0400)
test/javascript/util/box.js [new file with mode: 0644]

diff --git a/test/javascript/util/box.js b/test/javascript/util/box.js
new file mode 100644 (file)
index 0000000..d9947db
--- /dev/null
@@ -0,0 +1,51 @@
+describe('Foundation box', function () {
+    var $html;
+
+    afterEach(function () {
+        if ($html) {
+            $html.remove();
+        }
+    });
+
+    describe('GetDimensions()', function () {
+        it('should be unable to get dimensions for window', function(done) {
+            try {
+                Foundation.Box.GetDimensions($("window"));
+
+                should.fail();
+            } catch (err) {
+                done();
+            }
+        });
+
+        it('should be unable to get dimensions for document', function(done) {
+            try {
+                Foundation.Box.GetDimensions($("document"));
+
+                should.fail();
+            } catch (err) {
+                done();
+            }
+        });
+
+        it('height and width of element', function () {
+            $html = $('<div id="rect-test" style="height: 100px;width:200px;"></div>').appendTo('body');
+
+            var dims = Foundation.Box.GetDimensions($("#rect-test"));
+
+            dims.width.should.equal(200);
+            dims.height.should.equal(100);
+        });
+
+        it('parent height of element', function () {
+            $html = $('<div style="height: 200px;"><div id="rect-test-parent" style="height: 100px;width:200px;"></div></div>').appendTo('body');
+
+            var dims = Foundation.Box.GetDimensions($("#rect-test-parent"));
+
+            dims.width.should.equal(200);
+            dims.height.should.equal(100);
+
+            dims.parentDims.height.should.equal(200);           
+        });
+    });
+});
\ No newline at end of file