Qunit と Date.js を使用して、作成したいくつかの API 関数をテストしています。これが私のコードです:
asyncTest("createDeal", 4, function () {
var okStartDate = Date.today().addDays(4),
notOkStartDatePast = Date.today().addDays(-1),
notOkStartDateFuture = Date.today().addDays(1),
okEndDate,
notOkEndDateForOkStartDate;
okEndDate = okStartDate.addDays(8);
notOkEndDateForOkStartDate = okStartDate.addDays(1);
$.post(createApiUrl("deal/create/1"), {"start_date" : okStartDate, "end_date" : notOkEndDateForOkStartDate}, function(data) {
equal(data, '{"result":"fail"}', "The expected error was thrown");
});
$.post(createApiUrl("deal/create/1"), {"start_date" : notOkStartDatePast, "end_date" : okEndDate }, function(data) {
equal(data, '{"result" : "fail"}', "The expected error was thrown");
});
$.post(createApiUrl("deal/create/1"), {"start_date" : notOkStartDateFuture, "end_date" : okEndDate }, function(data) {
equal(data, '{"result" : "fail"}', "The expected error was thrown");
});
$.post(createApiUrl("deal/create/1"), {"start_date" : okStartDate, "end_date" : okEndDate }, function(data) {
equal(data, '{"result" : "success"}', "Params passed in were OK. Query ran OK.");
start();
});
});
Qunit は最初のテストでクラッシュし続け、次のように伝えています。
TypeError: Object [object DOMWindow] has no method 'getTime'
そして、asyncTest で関数全体をスローします。Qunit または Date.js のバグですか?