Commit 3b959393 authored by teravest@chromium.org's avatar teravest@chromium.org

Fix test for "last updated" text.

The minutes field was updated to be zero-padded, but the test wasn't, so the
test would fail at certain times of day. This updates that test to always pass.

NOTRY=true

Review URL: https://codereview.chromium.org/473433002

git-svn-id: svn://svn.chromium.org/blink/trunk@180231 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 498273d5
......@@ -22,10 +22,7 @@ found in the LICENSE file.
return date.getHours();
},
_minutes: function(date) {
var s = date.getMinutes().toString();
if (s.length == 1)
s = "0" + s;
return s;
return date.getMinutes().toString().padLeft(2, '0');
},
});
})();
......
......@@ -24,7 +24,7 @@ describe('ct-last-updated', function() {
it('should have correct text', function() {
var expected = 'Updated 5 min ago @ ' + lastUpdated.date.getHours() + ':' +
lastUpdated.date.getMinutes();
lastUpdated.date.getMinutes().toString().padLeft(2, '0');
assert.include(lastUpdated.shadowRoot.innerHTML.trim(), expected);
});
});
......@@ -43,7 +43,6 @@ describe('ct-last-updated', function() {
describe('Pad minutes when less than 10', function() {
beforeEach(function(done) {
lastUpdated = document.createElement('ct-last-updated');
// Set the date to 5 minutes ago.
lastUpdated.date = Date.create('11:05');
requestAnimationFrame(function() { done(); });
});
......@@ -54,6 +53,20 @@ describe('ct-last-updated', function() {
});
});
describe('Pad minutes when greater than 10', function() {
beforeEach(function(done) {
lastUpdated = document.createElement('ct-last-updated');
lastUpdated.date = Date.create('11:25');
requestAnimationFrame(function() { done(); });
});
it('should have correct text', function() {
var expected = '11:25';
assert.include(lastUpdated.shadowRoot.innerHTML.trim(), expected);
});
});
});
})()
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment