??????????????????????Ч????bug
???????????? ???????[ 2012/9/29 14:51:06 ] ????????
????Assertions
????assertion?????????????????????????????????????????????????????Assertions???????????????????assertion???ж????????????assertions??????????message????????????????
assert("Small date difference expected
'3 days?? 2 hours?? 16 minutes and " +
"10 seconds ago' got
'" + element.text() + "'"??
element.text() == "3 days?? 2 hours?? 16 minutes and 10 seconds ago");
????assert????????message??????????????message??????????????????????ú???????????assertion???????????message??淶???綨????????????????
???????????assert?????????????????????????????????????????????????????????????assertion??????????????????????Щ??????????????????????????????????Щ????assertEquals??????????????£?
assertEquals("3 days?? 2 hours?? 16 minutes and 10 seconds ago"?? element.text());
?????????????????????ж??????assertEquals??????????????????????????????????????????????????message??
??????????????setUp??tearDown
?????????????д??????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????????ò?????????????????????????????????????????????????????????????????????
var second = 1000;
var minute = 60 * second;
var hour = 60 * minute;
var day = 24 * hour;
TestCase("TimeDifferenceInWordsTest"?? {
"test 8 day difference should result in '1 week ago'": function () {
var dateStr = new Date(new Date() - 8 * day).toString();
var element = jQuery('Replace me');
element.differenceInWords();
assertEquals("1 week ago"?? element.text());
}??
"test should display difference with days?? hours?? minutes and seconds": function () {
var diff = 3 * day + 2 * hour + 16 * minute + 10 * second;
dateStr = new Date(new Date() - diff).toString();
var element = jQuery('Replace me');
element.differenceInWords();
assertEquals("3 days?? 2 hours?? 16 minutes and 10 seconds ago"?? element.text());
}
});
?????????????????????????????????????????????????assertion??????????????????????????????????????date??????????????????????setUp?????????????????????????????
TestCase("TimeDifferenceInWordsTest"?? {
setUp: function () {
this.date8DaysAgo = new Date(new Date() - 8 * day);
var diff = 3 * day + 2 * hour + 16 * minute + 10 * second;
this.date3DaysAgo = new Date(new Date() - diff);
}??
"test 8 day difference should result in '1 week ago'": function () {
var element = jQuery('Replace me');
element.differenceInWords();
assertEquals("1 week ago"?? element.text());
}??
"test should display difference with days?? hours?? minutes and seconds": function () {
var element = jQuery('Replace me');
element.differenceInWords();
assertEquals("3 days?? 2 hours?? 16 minutes and 10 seconds ago"?? element.text());
}
});
????setUp?????????????????????tearDown????????????????????С????????????tearDown????????????????????????β???????????????????????????????????????????????Щ??????洢??????????????????????????????????????????????????????????????
???????????????????????????Щ???????в????????JavaScript??????????????????????HTML?????????????????????????????????????????????HTML???????????????м??????????????????????????????????????????ú??????
??????
???·???
??????????????????
2023/3/23 14:23:39???д?ò??????????
2023/3/22 16:17:39????????????????????Щ??
2022/6/14 16:14:27??????????????????????????
2021/10/18 15:37:44???????????????
2021/9/17 15:19:29???·???????·
2021/9/14 15:42:25?????????????
2021/5/28 17:25:47??????APP??????????
2021/5/8 17:01:11