Y.Assert.isMatch - Match string against supplied Regex
Y.Assert.hasKey - Does Object have a specific key
Y.Assert.hasValue - Does Object have a specific value
Y.Assert.hasDeepKey - Validate key exists in a nested object
Y.Assert.hasDeepValue - Validate value exists in a nested object
Y.Assert.operator - Compare two values
Y.Assert.isNode - Validate a Dom Node exists
Y.Assert.nodeTextEquals - Validate text of a Dom node equals expected value
Y.Assert.nodeTextExists - Validate Dom node has text in it
Y.Assert.nodeCount - Validate selector counts(look at example below)
Y.Assert.nodeContains - Validate if given needle is within the HTML of a module
Y.Assert.isImage - Validate if Dom node is a valid image
Y.Assert.isAnchor - Validate if Dom node is a valid anchor
Y.Test.Module
Writing tests for a modular HTML component can be done using expressive JSON. Only requirements are to declare html-module, dom, common as Common Libs in your descriptor
YUI.add("MyAwesomeModule-tests", function (Y) {
'use strict';
var suite = new Y.Test.Suite("MyAwesomeModule Tests");
suite.add(new Y.Test.Module({
"name" : "MyAwesomeModule",
"id" : "myawesomemodule",
"asserts" : {
"Title" : ".hd h3",
"Body" : ".bd",
"Footer Link" : ".ft li",
"Test Equal To" : {
"locator" : ".bd ul li",
"type" : "nodeCount",
"expected" : "=4",
"message" : "There should be 4 Table Headers"
},
"Test Less Than" : {
"locator" : ".bd ul li.foo",
"type" : "nodeCount",
"expected" : ">30",
"message" : "There should be more than 30 list items with class foo"
},
"Test Greater Than" : {
"locator" : ".bd ul li.bar",
"type" : "nodeCount",
"expected" : "<10",
"message" : "There should be less than 10 list items with class bar"
},
"Test Node Contains" : {
"locator" : ".hd h3",
"type" : "nodeContains",
"expected" : "My Module Header"
},
"Test Node Text Exists" : {
"locator" : ".hd h3",
"type" : "nodeTextExists"
},
"Test Node" : {
"locator" : ".hd h3",
"type" : "isNode"
},
"Test Anchor" : {
"locator" : ".ft a",
"type" : "isAnchor"
},
"Test Image" : {
"locator" : ".bd ul li.logo img",
"type" : "isImage"
}
}
}));
Y.Test.Runner.add(suite);
}, "0.1", {requires : ["test", "node", "html-module-lib", "dom-lib"]});
New Asserts added:
Y.Test.Module
Writing tests for a modular HTML component can be done using expressive JSON. Only requirements are to declare html-module, dom, common as Common Libs in your descriptor