namespace.html revision 35cf6dd5c2320d93c353e64d1b4aa8c50ebf7722
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
<title>YUI Namespace Tests</title>
</head>
<body class="yui-skin-sam">
<h1>Namespace Tests</h1>
<p><input type="button" value="Run Tests" id="btnRun" disabled="true" /></p>
<script type="text/javascript" src="/build/yui/yui.js"></script>
<script type="text/javascript">
(function() {
YUI({
base: "/build/",
filter: "debug",
useConsole: true,
logExclude: {Dom: true, Selector: true, Node: true, attribute: true, base: true, event: true, widget: true}
}).use("dump", "test", "console", "event-custom", function(Y) {
var button = Y.get('#btnRun'),
Assert = Y.Assert;
// Set up the page
button.set("disabled", false);
Y.on("click", function() {
Y.Test.Runner.run();
}, button);
var myConsole = new Y.Console().render();
var testNamespace = new Y.Test.Case({
name: "Namespace tests",
test_create_namespace: function () {
// set up Y.my.namespace
var ns = Y.namespace("my.namespace");
// use the returned reference, assign a value
ns.test = "yahoo_my_namespace_test";
// check for the assigned value using the full path
Assert.areEqual(Y.my.namespace.test, "yahoo_my_namespace_test", "The namespace was not set up correctly");
// assign a value to my to test that it doesn't get wiped out
Y.my.test = "yahoo_my_test";
// create another namespace on my
var ns2 = Y.namespace("my.namespace2");
// make sure my stays the same
Assert.areEqual(Y.my.test, "yahoo_my_test", "The namespace was obliterated");
}
});
Y.Test.Runner.add(testNamespace);
Y.Test.Runner.run();
});
})();
</script>
</body>
</html>