From 8cbf36713975980633f989f89a4825bdda220d12 Mon Sep 17 00:00:00 2001 From: Derek Gathright Date: Tue, 27 Aug 2013 01:48:38 -0500 Subject: [PATCH] Added additional Widget tests --- src/widget/tests/unit/widget.html | 57 ++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/src/widget/tests/unit/widget.html b/src/widget/tests/unit/widget.html index 7d14f9cf685..25d226e0fe4 100644 --- a/src/widget/tests/unit/widget.html +++ b/src/widget/tests/unit/widget.html @@ -988,6 +988,41 @@ Y.Assert.areEqual("myWidget[foo]", w.toString()); + w.destroy(); + }, + + "testBoundingBoxWithSrcNode" : function() { + var w = this.createWidget({ + boundingBox: Y.Node.create(""), + srcNode: Y.Node.create("") + }); + + Y.Assert.areEqual("span", w.get("boundingBox").get("tagName").toLowerCase()); + Y.Assert.areEqual("span", w.get("contentBox").get("tagName").toLowerCase()); + Y.Assert.areEqual("bb", w.get("boundingBox").get("id")); + Y.Assert.areEqual("cb", w.get("contentBox").get("id")); + + w.destroy(); + }, + + "testOverridenBoundingBoxATTR" : function() { + function MyOtherWidget () { + MyOtherWidget.superclass.constructor.apply(this, arguments); + } + + Y.extend(MyOtherWidget, MyWidget, {}, { + NAME: 'MyOtherWidget', + ATTRS: { + boundingBox: { + value: Y.Node.create('
') + } + } + }); + + var w = new MyOtherWidget(); + + Y.Assert.areEqual("another-widget", w.get("boundingBox").get("id")); + w.destroy(); } }, true); @@ -1059,8 +1094,7 @@ w.render(); - // FIXME: Include after this is fixed: http://yuilibrary.com/projects/yui3/ticket/2530076, 2530311. - // Y.Assert.areSame(n, w.get("contentBox"), "srcNode not used as content box"); + Y.Assert.areSame(n, w.get("contentBox"), "srcNode not used as content box"); Y.Assert.isFalse(w.get("boundingBox").hasClass("yui3-mysingleboxwidget-loading"), "yui3-mysingleboxwidget-loading should have removed"); w.destroy(); @@ -1146,7 +1180,7 @@ w.destroy(); }, - // FIXME: Include after this is fixed: http://yuilibrary.com/projects/yui3/ticket/2530076, 2530311. + // FIXME: Include after this is fixed: http://yuilibrary.com/projects/yui3/ticket/2530076. "testContentBox" : null, /* @@ -1190,7 +1224,7 @@ w.destroy(); }, - // FIXME: Include after this is fixed: http://yuilibrary.com/projects/yui3/ticket/2530076, 2530311. + // FIXME: Include after this is fixed: http://yuilibrary.com/projects/yui3/ticket/2530076. "testContentBoxRenderTo" : null, /* @@ -1247,6 +1281,21 @@ Y.Assert.areEqual("mySingleBoxWidget[foo]", w.toString()); + w.destroy(); + }, + + "testBoundingBoxWithSrcNode" : function() { + var w = this.createWidget({ + boundingBox: Y.Node.create(""), + srcNode: Y.Node.create("") + }); + + // If CONTENT_TEMPLATE is null, CB resolves to BB (see: Widget#_setCB). + // While creating a single-box by specifying BB & srcNode probably doesn't, + // make sense, this test is here to ensure that changes to current behavior are + // considered before being made. + Y.Assert.isTrue(w.get("contentBox").compareTo(w.get("boundingBox")), "bb !== cb"); + w.destroy(); }