????????????????javascript??
???????????? ???????[ 2012/11/8 10:58:07 ] ????????
????????????????????????????????JsTestDriverд???????????????Javascript????????????????????JsTestDriver??(???)???з?????????????в??????·???????????HTML??????????????JsTestDriver?????????????????????????????????в????????????????????ι???????Ч??????????ж???
?????????jQuery?????src/difference_in_words.jquery.js????????????test/difference_in_words_test.js????????????????????????????????????????????jsTestDriver.conf??????????????????
????[plain] view plaincopy1. server: http://localhost:4224
????2.
????3. load:
????4. - src/*.js
????5. - test/*.js
????????????JsTestDriver.jar???°檔????????Java??????????????????????????(?????Windows????cmd.exe)??
????1. java -jar JsTestDriver-1.2.2.jar --port 4224
????????????????????????????JsTestDriver????????????????????????http://localhost:4224/capture??????????????????????????????д???(which will turn the browser into an idle test runningslave)????????????????????????????????????????????У?cd???????????????
????java -jar JsTestDriver-1.2.2.jar --tests all
????????????????????Щ?????JsTestDriver?????п?????????????е?????????????????????????????????????????????????????!????????????????????????????豸??????????????????????????????????(OS X?? Windows??Linux)?????iPhone?? Android?綽??????????豸????????????????????п?????????????????????????!
????JsTestDriver??????????????????????????????????????????????????QUnit?? YUI Test ?? Jasmineд?????????????YETI????????YUI??????????? Nicholas Zakas????????YUI TestStandalone???????????SeleniumWeb Driver???????????????
?????????????ò????????????
????????????????????????????????????????????????????????????????????еú???JavaScript?????????????????????????????(monkey patching)???????????????????????????????????????????
??????????????????д????????????????????ο????????????????е????д?Щ??????????????????????????????????????????д?????????????????????(????)???????????????????????(???)??????????????е????д??????????????????????????????????????????д???????????????????
?????????????????????????
????“???????”??????????????÷??????????????????????????ж????????????????????????????????????κ?????????????API?????????????????仰?????????????????????й?????????????????????????????????????????????????????????????/???????????????
??????????????????????????????????????jQuery????????????????????У?????????????8???????????ò??????????????“1 weekago”?????????????????????????????????????????????????????????κ?DOM?????????????????ò?????????????????????????????????????????????
???????jQuery????????????????????????????????????????????飺???????????????????????????????????????????DOM????innerHTML???????????? ??
?????????????????????????????????????????????????
????[javascript] view plaincopy1. var dateUtil = {};
????2.
????3. (function () {
????4. var units = {
????5. second: 1000??
????6. minute: 1000 * 60??
????7. hour: 1000 * 60 * 60??
????8. day: 1000 * 60 * 60 * 24??
????9. week: 1000 * 60 * 60 * 24 * 7??
????10. month: 1000 * 60 * 60 * 24 * 30
????11. };
????12.
????13. function format(num?? type) {
????14. return num + " " + type + (num > 1 ? "s" : "");
????15. }
????16.
????17. dateUtil.differenceInWords = function (date) {
????18. // return correct string
????19. };
????20.
????21. jQuery.fn.differenceInWords = function () {
????22. this.each(function () {
????23. var datetime = this.getAttribute("datetime");
????24. this.innerHTML = dateUtil.differenceInWords(new Date(datetime));
????25. });
????26. };
????27. }());
????????????????????????????????????????????????????jQuery??????μ??????????????????????????????????????????????????dateUtil.differenceInWords???????????????????????????????????????????jQuery???????????????????????滻????innerHTML ?????o??????????????????????????????????????????????????????????????
????[javascript] view plaincopy1. TestCase("TimeDifferenceInWordsTest"?? {
????2. setUp: function () {
????3. this.date8DaysAgo = new Date(new Date() - 8 * day);
????4. var diff = 3 * day + 2 * hour + 16 * minute + 10 * second;
????5. this.date3DaysAgo = new Date(new Date() - diff);
??????
???·???
??????????????????
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