HTML and CSS Reference
In-Depth Information
The strftime.js file contains the Date.prototype.strftime imple-
mentation presented in Listing 1.2 in Chapter 1, Automated Testing. Listing 3.2
shows the test script, save it in strftime _ test.js .
Listing 3.2 Date.prototype.strftime YUI test case
YUI({
combine: true,
timeout: 10000
}).use("node", "console", "test", function (Y) {
var assert = Y.Assert;
var strftimeTestCase = new Y.Test.Case({
// test case name - if not provided, one is generated
name: "Date.prototype.strftime Tests",
setUp: function () {
this.date = new Date(2009, 9, 2, 22, 14, 45);
},
tearDown: function () {
delete this.date;
},
"test %Y should return full year": function () {
var year = Date.formats.Y(this.date);
assert.isNumber(year);
assert.areEqual(2009, year);
},
"test %m should return month": function () {
var month = Date.formats.m(this.date);
assert.isString(month);
assert.areEqual("10", month);
},
"test %d should return date": function () {
assert.areEqual("02", Date.formats.d(this.date));
},
"test %y should return year as two digits": function () {
assert.areEqual("09", Date.formats.y(this.date));
},
Search WWH ::




Custom Search