From: Kristofer Krause Date: Thu, 6 Apr 2017 21:13:01 +0000 (-0400) Subject: start of Box unit tests X-Git-Tag: v6.4.0-rc1~79^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0f5cb0d3d4e3c66f4002af65ba749daf90581b2d;p=thirdparty%2Ffoundation%2Ffoundation-sites.git start of Box unit tests --- diff --git a/test/javascript/util/box.js b/test/javascript/util/box.js new file mode 100644 index 000000000..d9947db70 --- /dev/null +++ b/test/javascript/util/box.js @@ -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 = $('
').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 = $('
').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