diff options
author | Matěj Cepl <mcepl@redhat.com> | 2011-04-17 10:03:45 +0200 |
---|---|---|
committer | Matěj Cepl <mcepl@redhat.com> | 2011-06-05 14:44:43 +0200 |
commit | 174bd99957fa0566aa1f4ef3e122c7dcf484392f (patch) | |
tree | b7cea9575fdb80310ee105520fef47af907383c3 /lib/logger.js | |
parent | 0ccc730b8cf0f66a8e9a15cc07b5b6613fc0e015 (diff) | |
download | bugzilla-triage-174bd99957fa0566aa1f4ef3e122c7dcf484392f.tar.gz |
Make logger.timeSheetRecordsPrinter testeable and add unit test.
Diffstat (limited to 'lib/logger.js')
-rw-r--r-- | lib/logger.js | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/logger.js b/lib/logger.js index d4c5dc9..0b18c1b 100644 --- a/lib/logger.js +++ b/lib/logger.js @@ -74,22 +74,21 @@ function getBugzillaAbbr(url) { } exports.generateTimeSheet = function generateTimeSheet() { - var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs); + var docHTML = timeSheetRecordsPrinter(myStorage.storage.logs, new Date()); libbz.openURLInNewTab("data:text/html;charset=utf-8," + docHTML); }; -function timeSheetRecordsPrinter(records) { +exports.timeSheetRecordsPrinter = function timeSheetRecordsPrinter(records, date) { var commentBugRE = new RegExp("[bB]ug\\s+([0-9]+)","g"); // sort the records into temporary array var tmpArr = []; - var today = new Date(); - var todayStr = today.getFullYear() + "-" + - xrpc.leadingZero(today.getMonth()+1) + "-" + - xrpc.leadingZero(today.getDate()); + var dateStr = date.getFullYear() + "-" + + xrpc.leadingZero(date.getMonth()+1) + "-" + + xrpc.leadingZero(date.getDate()); var outStr = '<!DOCTYPE html>' + "<html><head>\n"+ "<meta charset='utf-8'/>\n"+ - "<title>TimeSheet-"+ todayStr + "</title>\n</head>\n<body>\n" + + "<title>TimeSheet-"+ dateStr + "</title>\n</head>\n<body>\n" + "<h1>TimeSheet</h1>\n"; for (var i in records) { |