<div id="testLogger"></div>
<script>
YUI().use('node', 'test-console', 'test', function (Y) {
//name of the test case - if not provided, one is auto-generated
name : "Data 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"
//---------------------------------------------------------------------
testName : function () {
var Assert = Y.Assert;
Assert.areEqual("test", this.data.name);
},
testYear : function () {
var Assert = Y.Assert;
Assert.areEqual(2007, this.data.year);
},
testBeta : function () {
var Assert = Y.Assert;
}
});
//name of the test case - if not provided, one is auto-generated
name : "Array Tests",
//---------------------------------------------------------------------
// setUp and tearDown methods - optional
//---------------------------------------------------------------------
/*
* Sets up data that is needed by each test.
*/
setUp : function () {
this.data = [0,1,2,3,4]
},
/*
* Cleans up everything that was created by setUp().
*/
tearDown : function () {
delete this.data;
},
//---------------------------------------------------------------------
// Test methods - names must begin with "test"
//---------------------------------------------------------------------
testPop : function () {
var Assert = Y.Assert;
var value = this.data.pop();
Assert.areEqual(4, value);
},
testPush : function () {
var Assert = Y.Assert;
this.data.push(5);
Assert.areEqual(5, this.data[5]);
},
testSplice : function () {
var Assert = Y.Assert;
this.data.splice(2, 1, 6, 7);
Assert.areEqual(6, this.data[2]);
Assert.areEqual(7, this.data[3]);
}
});
Y.example.test.ExampleSuite = new Y.Test.Suite("Example Suite");
//create the console
(new Y.Test.Console({
newestOnTop : false,
filters: {
pass: true,
fail: true
}
})).render('#testLogger');
//run the tests
});
</script>