????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???????????????м??????????????????????????????????????????ú??????