namespace.html revision 0771d781138a507b3e657573703f511291640bf3
<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">
(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() {
}, 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);
});
})();
</script>
</body>
</html>