upgrading to YUI 2.6
data tables are going to need some work yet, but the other stuff seems to be working 100%
This commit is contained in:
parent
a041e93da8
commit
20f8df1291
2106 changed files with 993560 additions and 237 deletions
443
www/extras/yui/tests/module.html
Normal file
443
www/extras/yui/tests/module.html
Normal file
|
|
@ -0,0 +1,443 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
|
||||
"http://www.w3.org/TR/html4/strict.dtd">
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="content-type" content="text/html; charset=utf-8">
|
||||
<title>YAHOO.widget.Module Tests</title>
|
||||
|
||||
<link type="text/css" rel="stylesheet" href="../build/logger/assets/logger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/yuitest/assets/testlogger.css" />
|
||||
<link type="text/css" rel="stylesheet" href="../build/calendar/assets/skins/sam/calendar.css" />
|
||||
|
||||
<script type="text/javascript" src="../build/yahoo/yahoo-min.js"></script>
|
||||
<script type="text/javascript" src="../build/dom/dom-min.js"></script>
|
||||
<script type="text/javascript" src="../build/event/event-min.js"></script>
|
||||
<script type="text/javascript" src="../build/logger/logger-min.js"></script>
|
||||
<script type="text/javascript" src="../build/yuitest/yuitest.js"></script>
|
||||
|
||||
<script type="text/javascript" src="../build/container/container-min.js"></script>
|
||||
|
||||
<style type="text/css">
|
||||
|
||||
</style>
|
||||
|
||||
<script type="text/javascript">
|
||||
|
||||
|
||||
YAHOO.util.Assert.isDOMElement = function (actual, message) {
|
||||
|
||||
if (!(YAHOO.lang.isObject(actual) && YAHOO.lang.isString(actual.nodeName) && actual.nodeType === 1)) {
|
||||
|
||||
YAHOO.util.Assert.fail(message || "Not a DOM element.");
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
YAHOO.util.Event.onDOMReady(function () {
|
||||
|
||||
var oLogger = new YAHOO.tool.TestLogger();
|
||||
|
||||
var oModule;
|
||||
|
||||
var Assert = YAHOO.util.Assert,
|
||||
Module = YAHOO.widget.Module;
|
||||
|
||||
var oTestCase = new YAHOO.tool.TestCase({
|
||||
|
||||
name: "Sample Test Case",
|
||||
|
||||
testConstructor: function () {
|
||||
|
||||
// Create a Module from existing markup
|
||||
|
||||
oModule = new Module("module1");
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
oModule = null;
|
||||
|
||||
|
||||
oModule = new Module(document.getElementById("module1"));
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
oModule = null;
|
||||
|
||||
|
||||
var oDIV = document.createElement("div");
|
||||
|
||||
oModule = new Module(oDIV);
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
oModule = null;
|
||||
oDIV = null;
|
||||
|
||||
oDIV = document.createElement("div");
|
||||
oDIV.id = "module2";
|
||||
|
||||
oModule = new Module(oDIV);
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
oModule = null;
|
||||
oDIV = null;
|
||||
|
||||
oDIV = document.createElement("div");
|
||||
oDIV.id = "module2";
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
oModule = null;
|
||||
oDIV = null;
|
||||
|
||||
|
||||
// Create a Module without existing markup
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
Assert.isObject(oModule, "Failed to create basic instance");
|
||||
Assert.isInstanceOf(Module, oModule, "Failed to create basic instance");
|
||||
|
||||
},
|
||||
|
||||
testProperties: function () {
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
Assert.areEqual(Module, oModule.constructor, "The Module's constructor is not YAHOO.widget.Module.");
|
||||
|
||||
Assert.isString(oModule.id, "The Module does not have an id.");
|
||||
|
||||
Assert.areEqual("module2", oModule.id, "The Module does not have an id.");
|
||||
|
||||
Assert.isString(oModule.platform, "The Module's \"platform\" property is not set.");
|
||||
|
||||
Assert.isString(oModule.browser, "The Module's \"browser\" property is not set.");
|
||||
|
||||
Assert.isBoolean(oModule.isSecure, "The Module's \"isSecure\" property is not set.");
|
||||
|
||||
oModule = null;
|
||||
|
||||
},
|
||||
|
||||
testConfigurationProperties: function () {
|
||||
|
||||
// Visible
|
||||
|
||||
oModule = new Module("module2", { visible: true });
|
||||
|
||||
oModule.setBody("This is the body");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isTrue(oModule.cfg.getProperty("visible"), "The value of the \"visible\" configuration property is not correct.");
|
||||
Assert.areEqual("block", oModule.element.style.display, "The Module is not visible when it should be.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
oModule.setBody("This is the body");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isTrue(oModule.cfg.getProperty("visible"), "The value of the \"visible\" configuration property is not correct.");
|
||||
Assert.areEqual("block", oModule.element.style.display, "The Module is not visible when it should be.");
|
||||
|
||||
oModule.cfg.setProperty("visible", false);
|
||||
|
||||
Assert.isFalse(oModule.cfg.getProperty("visible"), "The value of the \"visible\" configuration property is not correct.");
|
||||
Assert.areEqual("none", oModule.element.style.display, "The Module is not hidden when it should be.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2", { visible: false });
|
||||
oModule.setBody("This is the body");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isFalse(oModule.cfg.getProperty("visible"), "The value of the \"visible\" configuration property is not correct.");
|
||||
Assert.areEqual("none", oModule.element.style.display, "The Module is not hidden when it should be.");
|
||||
|
||||
oModule.cfg.setProperty("visible", true);
|
||||
|
||||
Assert.isTrue(oModule.cfg.getProperty("visible"), "The value of the \"visible\" configuration property is not correct.");
|
||||
Assert.areEqual("block", oModule.element.style.display, "The Module is not visible when it should be.");
|
||||
|
||||
|
||||
|
||||
},
|
||||
|
||||
testMethods: function () {
|
||||
|
||||
// Header methods
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oModule.setHeader("This is the header.");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.header, "The Module's header element not created.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
var oEM = document.createElement("em");
|
||||
oEM.innerHTML = "This is the header.";
|
||||
|
||||
oModule.setHeader(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.header, "The Module's header element not created.");
|
||||
Assert.areEqual(oEM, oModule.header.firstChild, "The Module's header element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the header.";
|
||||
|
||||
oModule.appendToHeader(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.header, "The Module's header element not created.");
|
||||
Assert.areEqual(oEM, oModule.header.firstChild, "The Module's header element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
// Body methods
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oModule.setBody("This is the body.");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.body, "The Module's body element not created.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("em");
|
||||
oEM.innerHTML = "This is the body.";
|
||||
|
||||
oModule.setBody(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.body, "The Module's body element not created.");
|
||||
Assert.areEqual(oEM, oModule.body.firstChild, "The Module's body element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the body.";
|
||||
|
||||
oModule.appendToBody(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.body, "The Module's header element not created.");
|
||||
Assert.areEqual(oEM, oModule.body.firstChild, "The Module's header element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
// Footer methods
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oModule.setFooter("This is the footer.");
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.footer, "The Module's footer element not created.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("em");
|
||||
oEM.innerHTML = "This is the footer.";
|
||||
|
||||
oModule.setFooter(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.footer, "The Module's footer element not created.");
|
||||
Assert.areEqual(oEM, oModule.footer.firstChild, "The Module's footer element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the footer.";
|
||||
|
||||
oModule.appendToFooter(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.isDOMElement(oModule.element, "The Module's root element not created.");
|
||||
Assert.isDOMElement(oModule.footer, "The Module's header element not created.");
|
||||
Assert.areEqual(oEM, oModule.footer.firstChild, "The Module's header element is not equal to what was set.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
// Render
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the body.";
|
||||
|
||||
oModule.setBody(oEM);
|
||||
oModule.render(document.body);
|
||||
|
||||
Assert.areEqual(document.body, oModule.element.parentNode, "The Module was not rendered into the body of the document.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the body.";
|
||||
|
||||
oModule.setBody(oEM);
|
||||
|
||||
var oRenderTarget = document.createElement("div");
|
||||
oRenderTarget.id = "rendertarget";
|
||||
|
||||
document.body.appendChild(oRenderTarget);
|
||||
|
||||
oModule.render("rendertarget");
|
||||
|
||||
Assert.areEqual(oRenderTarget, oModule.element.parentNode, "The Module was not rendered into the specified target element.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oEM = document.createElement("div");
|
||||
oEM.innerHTML = "This is the body.";
|
||||
|
||||
oModule.setBody(oEM);
|
||||
|
||||
var oModuleContainer = document.createElement("div");
|
||||
oModuleContainer.id = "modulecontainer";
|
||||
|
||||
oModule.render("rendertarget", oModuleContainer);
|
||||
|
||||
Assert.areEqual(oRenderTarget, oModule.element.parentNode, "The Module was not rendered into the specified target element.");
|
||||
Assert.areEqual(oModuleContainer, oModule.body.parentNode, "The Module's container is not the element that was specified.");
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
|
||||
// Show
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
oModule.setBody("This is the body");
|
||||
|
||||
oModule.render(document.body);
|
||||
|
||||
oModule.show();
|
||||
|
||||
Assert.areEqual("block", oModule.element.style.display, "The Module is not visible after calling the \"show\" method.");
|
||||
|
||||
|
||||
// Hide
|
||||
|
||||
oModule.hide();
|
||||
|
||||
Assert.areEqual("none", oModule.element.style.display, "The Module is not hidden after calling the \"hide\" method.");
|
||||
|
||||
|
||||
// toString
|
||||
|
||||
Assert.areEqual(("Module " + oModule.id), oModule.toString(), "The Module \"toString\" method is not returning the correct value.");
|
||||
|
||||
|
||||
// destroy
|
||||
|
||||
oModule.destroy();
|
||||
|
||||
Assert.areEqual(null, document.getElementById("module2"), "The Module was not successfully destroyed.");
|
||||
|
||||
|
||||
},
|
||||
|
||||
testEvents: function () {
|
||||
|
||||
var CustomEvent = YAHOO.util.CustomEvent;
|
||||
|
||||
oModule = new Module("module2");
|
||||
|
||||
Assert.isInstanceOf(CustomEvent, oModule.beforeInitEvent, "Module event \"beforeInitEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.initEvent, "Module event \"initEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.appendEvent, "Module event \"appendEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.beforeRenderEvent, "Module event \"beforeRenderEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.renderEvent, "Module event \"renderEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.changeHeaderEvent, "Module event \"changeHeaderEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.changeBodyEvent, "Module event \"changeBodyEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.changeFooterEvent, "Module event \"changeFooterEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.changeContentEvent, "Module event \"changeContentEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.destroyEvent, "Module event \"destroyEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.beforeShowEvent, "Module event \"beforeShowEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.showEvent, "Module event \"showEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.beforeHideEvent, "Module event \"beforeHideEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, oModule.hideEvent, "Module event \"hideEvent\" is not an instance of YAHOO.util.CustomEvent.");
|
||||
Assert.isInstanceOf(CustomEvent, YAHOO.widget.Module.textResizeEvent, "YAHOO.widget.Module.textResizeEvent is not an instance of YAHOO.util.CustomEvent.");
|
||||
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
YAHOO.tool.TestRunner.add(oTestCase);
|
||||
|
||||
if (parent && parent != window) {
|
||||
YAHOO.tool.TestManager.load();
|
||||
} else {
|
||||
YAHOO.tool.TestRunner.run();
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
</script>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<div id="module1">
|
||||
<div class="bd">The body of the module1</div>
|
||||
</div>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
Loading…
Add table
Add a link
Reference in a new issue