Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
base fork: jconniff/yui3
...
head fork: jconniff/yui3
Checking mergeability… Don't worry, you can still create the pull request.
  • 7 commits
  • 4 files changed
  • 0 commit comments
  • 2 contributors
View
219 src/base/tests/base-core.html
@@ -219,7 +219,7 @@
initOnly : {
writeOnce:"initOnly"
- }
+ }
};
Y.extend(AttrHost, Y.BaseCore);
@@ -344,9 +344,220 @@
}
});
+ function CoreTestsHost(config) {
+ CoreTestsHost.superclass.constructor.apply(this, arguments);
+ }
+
+ CoreTestsHost.NAME = "coreTestsHost";
+ CoreTestsHost.ATTRS = {
+ cloneDefaultObject : {
+ value : {
+ a:1,
+ b:2,
+ c:3
+ }
+ },
+
+ cloneDefaultArray : {
+ value : ["foo", "bar", "foobar"]
+ },
+
+ cloneDefaultString : {
+ value : "foo"
+ },
+
+ cloneDefaultOverride : {
+ value : {
+ a:1, b:2, c:3
+ },
+ cloneDefaultValue : false
+ },
+
+ cloneDefaultShallow : {
+ value : {
+ a: {foo: "bar"}
+ },
+ cloneDefaultValue : "shallow"
+ },
+
+ cloneDefaultDeep : {
+ value : {
+ a: {foo: "bar"}
+ },
+ cloneDefaultValue : "deep"
+ },
+
+ cloneDefaultComplex : {
+ value : new Y.BaseCore()
+ }
+ };
+ Y.extend(CoreTestsHost, Y.BaseCore);
+
+ var coreTemplate = {
+
+ name: "Core Tests",
+
+ testInit : function() {
+ var h = new CoreTestsHost();
+ Y.Assert.isTrue(h.get("initialized"));
+ },
+
+ testDestroy : function() {
+ var h = new CoreTestsHost();
+
+ Y.Assert.isFalse(h.get("destroyed"));
+
+ h.destroy();
+
+ Y.Assert.isTrue(h.get("destroyed"));
+ },
+
+ testToString : function() {
+ var h = new CoreTestsHost(),
+ re = /^coreTestsHost\[.*?\]$/,
+ str = h.toString();
+
+ Y.Assert.isTrue(re.test(str));
+ },
+
+ testCloneDefaultValueObject : function() {
+ var h = new CoreTestsHost(),
+ val = h.get("cloneDefaultObject");
+
+ Y.Assert.isTrue(CoreTestsHost.ATTRS.cloneDefaultObject.value !== val);
+
+ Y.ObjectAssert.areEqual({
+ a:1,
+ b:2,
+ c:3
+ }, val);
+ },
+
+ testCloneDefaultValueArray : function() {
+ var h = new CoreTestsHost(),
+ val = h.get("cloneDefaultArray");
+
+ Y.Assert.isTrue(CoreTestsHost.ATTRS.cloneDefaultArray.value !== val);
+ Y.ArrayAssert.itemsAreEqual(["foo", "bar", "foobar"], val);
+ },
+
+ testCloneDefaultValueString : function() {
+ var h = new CoreTestsHost(),
+ val = h.get("cloneDefaultString");
+
+ Y.Assert.isTrue(CoreTestsHost.ATTRS.cloneDefaultString.value === val);
+ },
+
+ testCloneDefaultComplex : function() {
+ var h = new CoreTestsHost(),
+ val = h.get("cloneDefaultComplex");
+
+ // Don't try to clone by default. We may hurt our backs
+ Y.Assert.isTrue(CoreTestsHost.ATTRS.cloneDefaultComplex.value === val);
+ },
+
+ testCloneDefaultShallow : function() {
+ var h = new CoreTestsHost(),
+ val = h.get("cloneDefaultShallow");
+
+ Y.Assert.isTrue(CoreTestsHost.ATTRS.cloneDefaultShallow.value !== val);
+ Y.Assert.isTrue(CoreTestsHost.ATTRS.cloneDefaultShallow.value.a === val.a);
+
+ Y.ObjectAssert.areEqual({
+ foo:"bar"
+ }, val.a);
+ },
+
+ testCloneDefaultDeep : function() {
+ var h = new CoreTestsHost(),
+ val = h.get("cloneDefaultDeep");
+
+ Y.Assert.isTrue(CoreTestsHost.ATTRS.cloneDefaultDeep.value !== val);
+ Y.Assert.isTrue(CoreTestsHost.ATTRS.cloneDefaultDeep.value.a !== val.a);
+
+ Y.ObjectAssert.areEqual({
+ foo:"bar"
+ }, val.a);
+ },
+
+ testCloneDefaultOverride : function() {
+ var h = new CoreTestsHost(),
+ val = h.get("cloneDefaultOverride");
+
+ Y.Assert.isTrue(CoreTestsHost.ATTRS.cloneDefaultOverride.value === val);
+
+ Y.ObjectAssert.areEqual({
+ a:1,
+ b:2,
+ c:3
+ }, val);
+ },
+
+ testInitializerDestructorInvocation : function() {
+
+ var expected = ["beforeConstructorTwo", "beforeConstructorOne", "initializerOne", "initializerTwo", "afterConstructorOne", "afterConstructorTwo", "destructorTwo", "destructorOne"],
+ actual = [],
+ initCfg = {
+ foo: 1
+ };
+
+ function One(cfg) {
+ actual.push("beforeConstructorOne");
+ One.superclass.constructor.apply(this, arguments);
+ actual.push("afterConstructorOne");
+ }
+
+ Y.extend(One, Y.BaseCore, {
+ initializer : function(cfg) {
+ Y.Assert.areSame(initCfg, cfg);
+ actual.push("initializerOne");
+ },
+ destructor : function() {
+ actual.push("destructorOne");
+ }
+ }, {
+ NAME : "one",
+ ATTRS : {
+ "a" : {
+ value: 1
+ }
+ }
+ });
+
+ function Two(cfg) {
+ actual.push("beforeConstructorTwo");
+ Two.superclass.constructor.apply(this, arguments);
+ actual.push("afterConstructorTwo");
+ }
+
+ Y.extend(Two, One, {
+ initializer : function(cfg) {
+ Y.Assert.areSame(initCfg, cfg);
+ actual.push("initializerTwo");
+ },
+ destructor : function() {
+ actual.push("destructorTwo");
+ }
+ }, {
+ NAME : "two",
+ ATTRS : {
+ "b" : {
+ value: 2
+ }
+ }
+ });
+
+ var o = new Two(initCfg);
+ o.destroy();
+
+ Y.ArrayAssert.itemsAreEqual(expected, actual);
+
+ }
+ };
+
var basicTemplate = {
- name: "Core Base Class Tests",
+ name: "Base Class Tests",
createHost : function(cfg) {
return new AttrHost(cfg);
@@ -654,7 +865,7 @@
var extendedTemplate = {
- name: "Core Extended Class Tests",
+ name: "Extended Class Tests",
createHost : function(cfg) {
return new ExtendedAttrHost(cfg);
@@ -969,6 +1180,8 @@
var suite = new Y.Test.Suite({name:"Base Core Unit Tests"});
+ suite.add(new Y.Test.Case(coreTemplate));
+
suite.add(new Y.Test.Case(basicTemplate));
suite.add(new Y.Test.Case(extendedTemplate));
View
472 src/base/tests/base.html
@@ -43,9 +43,134 @@
// NOTE: Attribute's unit tests cover a large section of Base's functionality when it comes to dealing with attributes.
+ function EventTests(config) {
+ EventTests.superclass.constructor.apply(this, arguments);
+ }
+
+ EventTests.NAME = "eventTestsHost";
+
+ EventTests.ATTRS = {
+ attr1 : {
+ value: "foo"
+ }
+ };
+
+ Y.extend(EventTests, Y.Base);
+
var suite = new Y.Test.Suite("Base Tests");
suite.add(new Y.Test.Case({
+ name : "Base Event Tests",
+
+ testEventPrefix : function() {
+ var h = new EventTests();
+ Y.Assert.areEqual("eventTestsHost", h._eventPrefix);
+ },
+
+ testEventRegistrationThroughConstructor : function() {
+
+ var expectedEvents = ["OnInit", "AfterInit", "OnAttr1Change", "AfterAttr1Change"];
+ var actualEvents = [];
+
+ var h = new EventTests({
+ on: {
+ "attr1Change" : function() {
+ actualEvents.push("OnAttr1Change");
+ },
+
+ "init" : function() {
+ actualEvents.push("OnInit");
+ }
+ },
+
+ after: {
+ "attr1Change" : function() {
+ actualEvents.push("AfterAttr1Change");
+ },
+
+ "init" : function() {
+ actualEvents.push("AfterInit");
+ }
+ }
+ });
+
+ h.set("attr1", "bar");
+
+ Y.ArrayAssert.itemsAreEqual(expectedEvents, actualEvents);
+ },
+
+ testBubbleTargetsThroughConstructor : function() {
+
+ var expectedEvents = ["bubbleTargetOne", "bubbleTargetTwo", "bubbleTargetThree"];
+ var actualEvents = [];
+
+ var bubbleTargetOne = new Y.EventTarget();
+ bubbleTargetOne.on("eventTestsHost:attr1Change", function() {
+ actualEvents.push("bubbleTargetOne");
+ });
+
+ var bubbleTargetTwo = new Y.EventTarget();
+ bubbleTargetTwo.on("eventTestsHost:attr1Change", function() {
+ actualEvents.push("bubbleTargetTwo");
+ });
+
+ var bubbleTargetThree = new Y.EventTarget();
+ bubbleTargetThree.on("eventTestsHost:attr1Change", function() {
+ actualEvents.push("bubbleTargetThree");
+ });
+
+ var h1 = new EventTests({
+ bubbleTargets : [bubbleTargetOne, bubbleTargetTwo]
+ });
+
+ h1.set("attr1", "bar");
+
+ var h2 = new EventTests({
+ bubbleTargets : bubbleTargetThree
+ });
+
+ h2.set("attr1", "foobar");
+
+ Y.ArrayAssert.itemsAreEqual(expectedEvents, actualEvents);
+ },
+
+ testInitEvent : function() {
+ var actual = [];
+ var expected = ["onInit", "afterInit"];
+
+ var h = new EventTests({
+ on : {
+ init : function() {
+ actual.push("onInit");
+ }
+ },
+ after : {
+ init : function() {
+ actual.push("afterInit");
+ }
+ }
+ });
+
+ Y.ArrayAssert.itemsAreEqual(expected, actual);
+ },
+
+ testDestroyEvent : function() {
+ var actual = [];
+ var expected = ["onDestroy", "afterDestroy"];
+
+ var h = new EventTests();
+
+ h.on("destroy", function() {
+ actual.push("onDestroy");
+ });
+
+ h.after("destroy", function() {
+ actual.push("afterDestroy");
+ });
+ }
+ }));
+
+ suite.add(new Y.Test.Case({
name : "BaseBuild",
@@ -828,6 +953,7 @@
});
var o = new MyClassTwo();
+
o.methodOne();
o.methodTwo();
o.extOne();
@@ -836,6 +962,304 @@
Y.ArrayAssert.itemsAreEqual(expectedMethodCalls, actualMethodCalls, "Unexpected method calls");
},
+ "test:mainclass-statics" : function() {
+
+ function Ext1() {}
+
+ Ext1.prototype.extOne = function() {};
+ Ext1.prototype.initializer = function() {};
+ Ext1.prototype.methodOne = function() {
+ return "methodOne";
+ };
+
+ Ext1.STATIC_ONE = "static_one";
+ Ext1.STATIC_TWO = "static_two";
+ Ext1.STATIC_THREE = "static_three";
+
+ var MyClass = Y.extend(function() {
+ MyClass.superclass.constructor.apply(this, arguments);
+ }, Y.Base, null, {
+ NAME : "myClass",
+ _buildCfg : {
+ statics : ["STATIC_ONE", "STATIC_TWO"]
+ }
+ });
+
+ var MyBuiltClass = Y.Base.create("myBuiltClass", MyClass, [Ext1]);
+
+ var o = new MyBuiltClass();
+
+ Y.Assert.isTrue(o instanceof MyBuiltClass);
+
+ Y.Assert.isFunction(o.methodOne); // prototype properties copied
+ Y.Assert.isFunction(o.init); // but prototype not switched completely by mistake
+
+ Y.Assert.areEqual("static_one", MyBuiltClass.STATIC_ONE);
+ Y.Assert.areEqual("static_two", MyBuiltClass.STATIC_TWO);
+ Y.Assert.isFalse("STATIC_THREE" in MyBuiltClass);
+
+ Y.Assert.isFalse(MyBuiltClass.ATTRS === Ext1.ATTRS, "Ext1.ATTRS shouldn't have been copied over, it should be aggregated");
+ },
+
+ "test:mainclass-statics" : function() {
+
+ function Ext1() {}
+
+ Ext1.prototype.extOne = function() {};
+ Ext1.prototype.initializer = function() {};
+ Ext1.prototype.methodOne = function() {
+ return "methodOne";
+ };
+
+ Ext1.STATIC_ONE = "static_one";
+ Ext1.STATIC_TWO = "static_two";
+ Ext1.STATIC_THREE = "static_three";
+
+ var MyClass = Y.extend(function() {
+ MyClass.superclass.constructor.apply(this, arguments);
+ }, Y.Base, null, {
+ NAME : "myClass",
+ _buildCfg : {
+ statics : ["STATIC_ONE", "STATIC_TWO"]
+ }
+ });
+
+ var MyBuiltClass = Y.Base.create("myBuiltClass", MyClass, [Ext1]);
+
+ var o = new MyBuiltClass();
+
+ Y.Assert.isTrue(o instanceof MyBuiltClass);
+
+ Y.Assert.isFunction(o.methodOne); // prototype properties copied
+ Y.Assert.isFunction(o.init); // but prototype not switched completely by mistake
+
+ Y.Assert.areEqual("static_one", MyBuiltClass.STATIC_ONE);
+ Y.Assert.areEqual("static_two", MyBuiltClass.STATIC_TWO);
+ Y.Assert.isFalse("STATIC_THREE" in MyBuiltClass);
+
+ Y.Assert.isFalse(MyBuiltClass.ATTRS === Ext1.ATTRS, "Ext1.ATTRS shouldn't have been copied over, it should be aggregated");
+ },
+
+ "test:mainclass-aggregates" : function() {
+
+ function Ext1() {}
+ Ext1.AGG = {
+ "foo": true
+ };
+
+ function Ext2() {}
+ Ext2.AGG = {
+ "bar": true
+ };
+
+ var MyClass = Y.extend(function() {
+ MyClass.superclass.constructor.apply(this, arguments);
+ }, Y.Base, null, {
+ NAME : "myClass",
+ _buildCfg : {
+ aggregates : ["AGG"]
+ }
+ });
+
+ var MyBuiltClass = Y.Base.create("myBuiltClass", MyClass, [Ext1, Ext2]);
+
+ var o = new MyBuiltClass();
+
+ Y.ObjectAssert.areEqual({
+ foo:true,
+ bar:true
+ }, MyBuiltClass.AGG);
+ },
+
+ "test:mainclass-custom" : function() {
+
+ function Ext1() {}
+
+ Ext1.prototype.extOne = function() {};
+ Ext1.prototype.methodOne = function() {
+ return "methodOne";
+ };
+
+ Ext1.CUST = {
+ foo: [1],
+ bar: [1]
+ };
+
+ function Ext2() {}
+
+ Ext2.prototype.extTwo = function() {};
+ Ext2.prototype.methodTwo = function() {
+ return "methodOne";
+ };
+
+ Ext2.CUST = {
+ foo: [2, 3],
+ bar: [2, 3, 4]
+ };
+
+ // ---
+
+ var MyClass = Y.extend(function() {
+ MyClass.superclass.constructor.apply(this, arguments);
+ }, Y.Base, null, {
+ NAME : "myClass",
+ _buildCfg : {
+ custom : {
+ CUST : function(p, r, s) {
+
+ r[p] = r[p] || {
+ foo:[],
+ bar:[]
+ };
+
+ if (s[p]) {
+ if (s[p].foo) {
+ r[p].foo = r[p].foo.concat(s[p].foo);
+ }
+ if (s[p].bar) {
+ r[p].bar = r[p].bar.concat(s[p].bar);
+ }
+ }
+
+ }
+ }
+ }
+ });
+
+ var MyClass1 = Y.Base.create("myClass1", MyClass, [Ext1]);
+ var myclass1 = new MyClass1();
+
+ Y.Assert.isTrue(myclass1 instanceof MyClass1);
+
+ Y.Assert.isFunction(myclass1.methodOne);
+ Y.Assert.isFunction(myclass1.init);
+
+ // ObjectAssert.areEqual doesn't work: values don't == compare
+ Y.ObjectAssert.hasKeys({
+ bar:[1],
+ foo:[1]
+ }, MyClass1.CUST, "Class1 - object assert");
+
+ Y.ArrayAssert.itemsAreEqual([1], MyClass1.CUST.foo, "Class1 foo assert");
+ Y.ArrayAssert.itemsAreEqual([1], MyClass1.CUST.bar, "Class1 bar assert");
+
+ Y.Assert.isFalse(MyClass1.CUST === Ext1.CUST, "Ext1.CUST shouldn't have been copied over");
+
+ // ---
+
+ var MyClass2 = Y.Base.create("myClass2", MyClass, [Ext1, Ext2]);
+ var myclass2 = new MyClass2();
+
+ Y.Assert.isTrue(myclass2 instanceof MyClass2);
+
+ Y.Assert.isFunction(myclass2.methodTwo); // prototype properties copied
+ Y.Assert.isFunction(myclass2.init); // but prototype not switched completely by mistake
+
+ // ObjectAssert.areEqual doesn't work: values don't == compare
+ Y.ObjectAssert.hasKeys({
+ foo:[1,2,3],
+ bar:[1,2,3,4]
+ }, MyClass2.CUST);
+
+ Y.ArrayAssert.itemsAreEqual([1,2,3], MyClass2.CUST.foo);
+ Y.ArrayAssert.itemsAreEqual([1,2,3,4], MyClass2.CUST.bar);
+
+ Y.Assert.isFalse(MyClass2.CUST === Ext1.CUST, "Ext1.CUST shouldn't have been copied over");
+ Y.Assert.isFalse(MyClass2.CUST === Ext2.CUST, "Ext2.CUST shouldn't have been copied over");
+ },
+
+ "test:extCfg-custom" : function() {
+
+ function Ext1() {}
+
+ Ext1.prototype.extOne = function() {};
+ Ext1.prototype.methodOne = function() {
+ return "methodOne";
+ };
+
+ Ext1.CUST = {
+ foo: [1],
+ bar: [1]
+ };
+
+ Ext1._buildCfg = {
+ custom : {
+ CUST : function(p, r, s) {
+
+ r[p] = r[p] || {
+ foo:[],
+ bar:[]
+ };
+
+ if (s[p]) {
+ if (s[p].foo) {
+ r[p].foo = r[p].foo.concat(s[p].foo);
+ }
+ if (s[p].bar) {
+ r[p].bar = r[p].bar.concat(s[p].bar);
+ }
+ }
+
+ }
+ }
+ };
+
+ function Ext2() {}
+
+ Ext2.prototype.extTwo = function() {};
+ Ext2.prototype.methodTwo = function() {
+ return "methodOne";
+ };
+
+ Ext2.CUST = {
+ foo: [2, 3],
+ bar: [2, 3, 4]
+ };
+
+ // ---
+
+ var MyClass1 = Y.Base.create("myClass1", Y.Base, [Ext1]);
+ var myclass1 = new MyClass1();
+
+ Y.Assert.isTrue(myclass1 instanceof MyClass1);
+
+ Y.Assert.isFunction(myclass1.methodOne);
+ Y.Assert.isFunction(myclass1.init);
+
+ // ObjectAssert.areEqual doesn't work: values don't == compare
+ Y.ObjectAssert.hasKeys({
+ bar:[1],
+ foo:[1]
+ }, MyClass1.CUST, "Class1 - object assert");
+
+ Y.ArrayAssert.itemsAreEqual([1], MyClass1.CUST.foo, "Class1 foo assert");
+ Y.ArrayAssert.itemsAreEqual([1], MyClass1.CUST.bar, "Class1 bar assert");
+
+ Y.Assert.isFalse(MyClass1.CUST === Ext1.CUST, "Ext1.CUST shouldn't have been copied over");
+
+ // ---
+
+ var MyClass2 = Y.Base.create("myClass2", Y.Base, [Ext1, Ext2]);
+ var myclass2 = new MyClass2();
+
+ Y.Assert.isTrue(myclass2 instanceof MyClass2);
+
+ Y.Assert.isFunction(myclass2.methodTwo); // prototype properties copied
+ Y.Assert.isFunction(myclass2.init); // but prototype not switched completely by mistake
+
+ // ObjectAssert.areEqual doesn't work: values don't == compare
+ Y.ObjectAssert.hasKeys({
+ foo:[1,2,3],
+ bar:[1,2,3,4]
+ }, MyClass2.CUST);
+
+ Y.ArrayAssert.itemsAreEqual([1,2,3], MyClass2.CUST.foo);
+ Y.ArrayAssert.itemsAreEqual([1,2,3,4], MyClass2.CUST.bar);
+
+ Y.Assert.isFalse(MyClass2.CUST === Ext1.CUST, "Ext1.CUST shouldn't have been copied over");
+ Y.Assert.isFalse(MyClass2.CUST === Ext2.CUST, "Ext2.CUST shouldn't have been copied over");
+ },
+
"test:extCfg-statics" : function() {
function Ext1() {}
@@ -1025,6 +1449,54 @@
Y.Assert.isFalse(MyClass2.CUST === Ext1.CUST, "Ext1.CUST shouldn't have been copied over");
Y.Assert.isFalse(MyClass2.CUST === Ext2.CUST, "Ext2.CUST shouldn't have been copied over");
+ },
+
+ "test:deprecated" : function() {
+
+ function Ext1() {}
+
+ Ext1.MY_AGG = {a:1};
+ Ext1.MY_STATICS = "a";
+ Ext1.MY_CUSTOM = "a";
+
+ function Ext2() {}
+
+ Ext2.MY_AGG = {b:2};
+ Ext2.MY_STATICS = "b";
+ Ext2.MY_CUSTOM = "b";
+
+ function Ext3() {}
+
+ Ext3.MY_AGG = {c:3};
+ Ext3.MY_STATICS = "c";
+ Ext3.MY_CUSTOM = "c";
+
+ function MyMainClass(cfg) {
+ MyMainClass.superclass.constructor.apply(this, arguments);
+ }
+
+ var MyBuiltClass = Y.Base.build("foo", MyMainClass, [Ext1, Ext2, Ext3], {
+ dynamic: true,
+ aggregates : ["MY_AGG"],
+ statics : ["MY_STATICS"],
+ custom : {
+ MY_CUSTOM : function(prop, r, s) {
+ r[prop] = r[prop] || "";
+ r[prop] = r[prop] + s[prop];
+ }
+ }
+ });
+
+ Y.ObjectAssert.areEqual({
+ a:1,
+ b:2,
+ c:3
+ }, MyBuiltClass.MY_AGG);
+
+ Y.Assert.areEqual("c", MyBuiltClass.MY_STATICS);
+
+ /* Currently broken. Will fix in 3.6.0pr1. Too late at this point, given the extreme edge caseness. */
+ // Y.Assert.areEqual("abc", MyBuiltClass.MY_CUSTOM);
}
}));
View
2  src/overlay/docs/partials/overlay-align-source.mustache
@@ -63,7 +63,7 @@ YUI().use("overlay", function(Y) {
/* Setup local variable for Y.WidgetPositionAlign, since we use it multiple times */
var a = Y.WidgetPositionAlign,
- declareA = "var a = Y.WidgetPostionAlign; // Local variable<br><br>",
+ declareA = "var a = Y.WidgetPositionAlign; // Local variable<br><br>",
dontDeclareA = "<br><br>";
var steps = [
View
73 src/widget/tests/widget.html
@@ -842,6 +842,35 @@
widget.destroy(true);
Y.Assert.isTrue(gotFocus, "widget.on('focus') wasn't invoked");
+ },
+
+ "testToString" : function() {
+ var w = this.createWidget({
+ id: "foo"
+ });
+
+ Y.Assert.areEqual("widget[foo]", w.toString());
+
+ w.destroy();
+ },
+
+ "testDeprecated" : function() {
+ var w = this.createWidget({
+ strings: {
+ a:"strA",
+ b:"strB"
+ }
+ });
+
+ Y.Assert.areEqual("strA", w.getString("a"));
+ Y.Assert.areEqual("strB", w.getString("b"));
+
+ Y.ObjectAssert.areEqual({
+ a:"strA",
+ b:"strB"
+ }, w.getStrings());
+
+ w.destroy();
}
};
@@ -896,6 +925,16 @@
var w = this.createWidget();
Y.Assert.areEqual("yui3-mywidget-foo-bar", w.getClassName("foo", "bar"));
w.destroy();
+ },
+
+ "testToString" : function() {
+ var w = this.createWidget({
+ id: "foo"
+ });
+
+ Y.Assert.areEqual("myWidget[foo]", w.toString());
+
+ w.destroy();
}
}, true);
@@ -1150,7 +1189,17 @@
// CONSCIOUSLY NOT TESTED - CAN'T PASS 2 BOXES TO A SINGLE BOX WIDGET
"testBoundingBoxContentBox" : null,
- "testBoundingBoxContentBoxRenderTo" : null
+ "testBoundingBoxContentBoxRenderTo" : null,
+
+ "testToString" : function() {
+ var w = this.createWidget({
+ id: "foo"
+ });
+
+ Y.Assert.areEqual("mySingleBoxWidget[foo]", w.toString());
+
+ w.destroy();
+ }
}, true);
@@ -2080,6 +2129,28 @@
w1.destroy();
w2.destroy();
+ },
+
+ testPublishDefaultFn : function() {
+ var w = new Y.Widget({
+ render:true
+ }),
+ called = false;
+
+ w.publish("click", {
+ defaultFn : function(e) {
+ called = true;
+ Y.Assert.areEqual("click", e.domEvent.type);
+ }
+ });
+
+ w.get("contentBox").simulate("click");
+
+ //this.wait(function() {
+ Y.Assert.isTrue(called);
+ //}, 0);
+
+ w.destroy();
}
}));

No commit comments for this range

Something went wrong with that request. Please try again.