test-async-test-source.mustache revision 1b7d9ee6f1128c8cb5e16c3a11ba045998296171
<div id="testLogger"></div>
<script>
YUI().use('node', 'console', 'test',function (Y) {
Y.namespace("example.test");
Y.example.test.AsyncTestCase = new Y.Test.Case({
//name of the test case - if not provided, one is auto-generated
name : "Asynchronous Tests",
//---------------------------------------------------------------------
// setUp and tearDown methods - optional
//---------------------------------------------------------------------
/*
* Sets up data that is needed by each test.
*/
setUp : function () {
this.data = {
name: "test",
year: 2007,
beta: true
};
},
/*
* Cleans up everything that was created by setUp().
*/
tearDown : function () {
delete this.data;
},
//---------------------------------------------------------------------
// Test methods - names must begin with "test"
//---------------------------------------------------------------------
testWait : function (){
var Assert = Y.Assert;
//do some assertions now
Assert.isTrue(this.data.beta);
Assert.isNumber(this.data.year);
//wait five seconds and do some more
this.wait(function(){
Assert.isString(this.data.name);
}, 5000);
}
});
//create the console
var r = new Y.Console({
newestOnTop : false,
style: 'block' // to anchor in the example content
});
r.render('#testLogger');
Y.Test.Runner.add(Y.example.test.AsyncTestCase);
//run the tests
Y.Test.Runner.run();
});
</script>