| Index: Tools/GardeningServer/ui/test/ct-last-updated-tests.html
|
| diff --git a/Tools/GardeningServer/ui/test/ct-last-updated-tests.html b/Tools/GardeningServer/ui/test/ct-last-updated-tests.html
|
| index 80750ab01f3d8be7efe5996e189dbe867088b527..8f56d90d5b0b53f77802d4642063cab0d929336a 100644
|
| --- a/Tools/GardeningServer/ui/test/ct-last-updated-tests.html
|
| +++ b/Tools/GardeningServer/ui/test/ct-last-updated-tests.html
|
| @@ -12,22 +12,48 @@ found in the LICENSE file.
|
| var assert = chai.assert;
|
|
|
| describe('ct-last-updated', function() {
|
| - var builder;
|
| + var lastUpdated;
|
| +
|
| + describe('Updated 5 minutes ago', function() {
|
| + beforeEach(function(done) {
|
| + lastUpdated = document.createElement('ct-last-updated');
|
| + // Set the date to 5 minutes ago.
|
| + lastUpdated.date = new Date(Date.now() - (5 * 60 * 1000));
|
| + requestAnimationFrame(function() { done(); });
|
| + });
|
|
|
| - beforeEach(function(done) {
|
| - builder = document.createElement('ct-last-updated');
|
| - // Set the date to 5 minutes ago.
|
| - builder.date = new Date(Date.now() - (5 * 60 * 1000));
|
| - requestAnimationFrame(function() { done(); });
|
| + it('should have correct text', function() {
|
| + var expected = 'Updated 5 min ago @ ' + lastUpdated.date.getHours() + ':' +
|
| + lastUpdated.date.getMinutes();
|
| + assert.include(lastUpdated.shadowRoot.innerHTML.trim(), expected);
|
| + });
|
| });
|
|
|
| - describe('default UI', function() {
|
| + describe('No updated data', function() {
|
| + beforeEach(function(done) {
|
| + lastUpdated = document.createElement('ct-last-updated');
|
| + requestAnimationFrame(function() { done(); });
|
| + });
|
| +
|
| + it('no text should be visible', function() {
|
| + assert.notInclude(lastUpdated.shadowRoot.querySelector('template').innerHTML.trim(), "Updated");
|
| + });
|
| + });
|
| +
|
| + 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(); });
|
| + });
|
| +
|
| it('should have correct text', function() {
|
| - var expected = 'Updated 5 min ago @ ' + builder.date.getHours() + ':' +
|
| - builder.date.getMinutes();
|
| - assert.equal(builder.shadowRoot.innerHTML.trim(), expected);
|
| + var expected = '11:05';
|
| + assert.include(lastUpdated.shadowRoot.innerHTML.trim(), expected);
|
| });
|
| });
|
| +
|
| });
|
|
|
| })()
|
|
|