YUI({logInclude : { TestRunner: true }}).use("test", "test-console", "console", function (Y) { var Test = { drawConsole : function(){ var console = new Y.Test.Console({ newestOnTop : false, filters: { pass: true, fail: true, info: true } }); console.render('#testLogger'); }, testBegin : function(){ var testCase1 = new Y.Test.Case({ name : "Data Tests", setUp : function(){ this.data = { name : "test", year : 2007, beta : true }; }, tearDown : function(){ if(this.data){ delete this.data; } }, testName: function(){ var assert = Y.Assert; assert.isObject(this.data); assert.isString(this.data.name); assert.areEqual("test", this.data.name); }, testYear : function(){ var assert = Y.Assert; assert.isObject(this.data); assert.isNumber(this.data.year); assert.areEqual(2007, this.data.year); assert.areEqual("2007", this.data.year); assert.areSame(2007, this.data.year); assert.areSame("2007", this.data.year); }, testBeta : function(){ var assert = Y.Assert; assert.isObject(this.data); assert.isBoolean(this.data.beta); assert.isTrue(this.data.beta); } }); var testCase2 = new Y.Test.Case({ name : "Array Tests", setUp : function () { this.data = [0, 1, 2, 3, 4]; }, tearDown : function () { if(this.data){ delete this.data; } }, testPop : function () { var Assert = Y.Assert; var value = this.data.pop(); Assert.areEqual(4, this.data.length); Assert.areEqual(4, value); }, testPush : function () { var Assert = Y.Assert; this.data.push(5); Assert.areEqual(6, this.data.length); Assert.areEqual(5, this.data[5]); }, testSplice : function () { var Assert = Y.Assert; this.data.splice(2, 1, 6, 7); Assert.areEqual(6, this.data.length); Assert.areEqual(6, this.data[2]); Assert.areEqual(7, this.data[3]); } }); var testSuite = new Y.Test.Suite("Example Suite"); testSuite.add(testCase1); testSuite.add(testCase2); Y.Test.Runner.add(testSuite); Y.Test.Runner.run(); }, init : function(){ this.drawConsole(); this.testBegin(); } } Test.init(); }); |