Skip to content
Browse files

Add enyo.Control.getBounds() test as penance for checking in broken c…

…ode.

Enyo-DCO-1.1-Signed-Off-By: Ben Combee (ben.combee@palm.com)
  • Loading branch information...
1 parent d56f14d commit a1b3af2a6d44da5401e6d4a3ad6c7b1e3bbf803a Ben Combee committed Dec 27, 2012
Showing with 28 additions and 0 deletions.
  1. +28 −0 tools/test/core/tests/ControlTest.js
View
28 tools/test/core/tests/ControlTest.js
@@ -60,5 +60,33 @@ enyo.kind({
document.body.removeChild(div);
}
this.finish();
+ },
+ testGetBounds: function() {
+ var K = enyo.kind({
+ style: "position: absolute; top: 10px; height: 30px; left: 15px; width: 35px;"
+ });
+ // create new div, attach to start of body, delete at end
+ // needed because we need live DOM with getElementById working
+ var div = document.createElement("div");
+ document.body.appendChild(div);
+
+ var k = new K();
+ var b;
+ b = k.getBounds();
+ if (b.top !== undefined || b.left !== undefined || b.height !== undefined || b.width !== undefined) {
+ throw("bad bounds, expected all undefined, got " + JSON.stringify(b));
+ }
+ k.renderInto(div);
+ try {
+ b = k.getBounds();
+ if (b.top !== 10 || b.left !== 15 || b.height !== 30 || b.width !== 35) {
+ throw("bad bounds, expected {top: 10, left: 15, height: 30, width: 35}, got " + JSON.stringify(b));
+ }
+ } finally {
+ // clean up after our test
+ k.destroy();
+ document.body.removeChild(div);
+ }
+ this.finish();
}
});

0 comments on commit a1b3af2

Please sign in to comment.
Something went wrong with that request. Please try again.