diff options
Diffstat (limited to 'polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html')
-rw-r--r-- | polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html | 35 |
1 files changed, 27 insertions, 8 deletions
diff --git a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html index 2c15ef6750..ad4d0daced 100644 --- a/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html +++ b/polygerrit-ui/app/elements/shared/gr-date-formatter/gr-date-formatter_test.html @@ -1,5 +1,6 @@ <!DOCTYPE html> <!-- +@license Copyright (C) 2015 The Android Open Source Project Licensed under the Apache License, Version 2.0 (the "License"); @@ -55,7 +56,8 @@ limitations under the License. return d; } - function testDates(nowStr, dateStr, expected, expectedTooltip, done) { + function testDates(nowStr, dateStr, expected, expectedWithDateAndTime, + expectedTooltip, done) { // Normalize and convert the date to mimic server response. dateStr = normalizedDate(dateStr) .toJSON().replace('T', ' ').slice(0, -1); @@ -65,6 +67,9 @@ limitations under the License. const span = element.$$('span'); assert.equal(span.textContent.trim(), expected); assert.equal(element.title, expectedTooltip); + element.showDateAndTime = true; + flushAsynchronousOperations(); + assert.equal(span.textContent.trim(), expectedWithDateAndTime); done(); }); } @@ -98,25 +103,33 @@ limitations under the License. test('Within 24 hours on same day', done => { testDates('2015-07-29 20:34:14.985000000', '2015-07-29 15:34:14.985000000', - '15:34', 'Jul 29, 2015, 15:34:14', done); + '15:34', + '15:34', + 'Jul 29, 2015, 15:34:14', done); }); test('Within 24 hours on different days', done => { testDates('2015-07-29 03:34:14.985000000', '2015-07-28 20:25:14.985000000', - 'Jul 28', 'Jul 28, 2015, 20:25:14', done); + 'Jul 28', + 'Jul 28 20:25', + 'Jul 28, 2015, 20:25:14', done); }); test('More than 24 hours but less than six months', done => { testDates('2015-07-29 20:34:14.985000000', '2015-06-15 03:25:14.985000000', - 'Jun 15', 'Jun 15, 2015, 03:25:14', done); + 'Jun 15', + 'Jun 15 03:25', + 'Jun 15, 2015, 03:25:14', done); }); test('More than six months', done => { testDates('2015-09-15 20:34:00.000000000', '2015-01-15 03:25:00.000000000', - 'Jan 15, 2015', 'Jan 15, 2015, 03:25:00', done); + 'Jan 15, 2015', + 'Jan 15, 2015 03:25', + 'Jan 15, 2015, 03:25:00', done); }); }); @@ -135,7 +148,9 @@ limitations under the License. test('Within 24 hours on same day', done => { testDates('2015-07-29 20:34:14.985000000', '2015-07-29 15:34:14.985000000', - '3:34 PM', 'Jul 29, 2015, 3:34:14 PM', done); + '3:34 PM', + '3:34 PM', + 'Jul 29, 2015, 3:34:14 PM', done); }); }); @@ -153,13 +168,17 @@ limitations under the License. test('Within 24 hours on same day', done => { testDates('2015-07-29 20:34:14.985000000', '2015-07-29 15:34:14.985000000', - '5 hours ago', 'Jul 29, 2015, 3:34:14 PM', done); + '5 hours ago', + '5 hours ago', + 'Jul 29, 2015, 3:34:14 PM', done); }); test('More than six months', done => { testDates('2015-09-15 20:34:00.000000000', '2015-01-15 03:25:00.000000000', - '8 months ago', 'Jan 15, 2015, 3:25:00 AM', done); + '8 months ago', + '8 months ago', + 'Jan 15, 2015, 3:25:00 AM', done); }); }); |