Skip to content

Commit

Permalink
Improved browser unit test.
Browse files Browse the repository at this point in the history
  • Loading branch information
martini authored and thorsteneckel committed Dec 15, 2018
1 parent e76d5a7 commit defbd95
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions public/assets/tests/ui.js
Expand Up @@ -241,7 +241,7 @@ test("check pretty date", function() {

result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 5.5), escalation, long, type);
diff = 60 * 60 * 24 * 5.5
equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 24 * 5.5)), diff), 'in 30.5 days')
equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 24 * 5.5)), diff), 'in 5.5 days')

result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 30.5), escalation, long, type);
diff = (60 * 60 * 24 * 30.5);
Expand Down Expand Up @@ -323,7 +323,7 @@ test("check pretty date", function() {
equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 24 * 2.5))), 'in 2.5 days')

result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 5.5), escalation, long, type);
equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 24 * 5.5))), 'in 30.5 days')
equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 24 * 5.5))), 'in 5.5 days')

result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 30.5), escalation, long, type);
equal(result, getTimestamp(new Date(current.getTime() + 60050 * 60 * 24 * 30.5)), 'in 30.5 days')
Expand All @@ -337,14 +337,20 @@ test("check pretty date", function() {
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
month = months[date.getMonth()];

d = date.getDate()
m = date.getMonth() + 1
yfull = date.getFullYear()
M = date.getMinutes()
H = date.getHours()

// for less than 6 days
// weekday HH::MM
if (diff < (60 * 60 * 24 * 6))
string = weekday + ' ' + date.getHours() + ':' + (date.getMinutes() < 10 ? '0':'') + date.getMinutes()
else if (current.getYear() == date.getYear())
string = weekday + ' ' + date.getDate() + '. ' + month + ' ' + date.getHours() + ":" + (date.getMinutes() < 10 ? '0':'') + date.getMinutes()
string = weekday + ' ' + date.getDate() + '. ' + month + ' ' + (H < 10 ? '0':'') + H + ":" + (M < 10 ? '0':'') + M
else
string = weekday + ' ' + date
string = weekday + ' ' + (m < 10 ? '0':'') + m + '/' + (d < 10 ? '0':'') + d + '/' + (yfull) + ' ' + (H < 10 ? '0':'') + H + ":" + (M < 10 ? '0':'') + M
return string;
}

Expand Down

0 comments on commit defbd95

Please sign in to comment.