OLD | NEW |
---|---|
1 <!-- | 1 <!-- |
2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
4 found in the LICENSE file. | 4 found in the LICENSE file. |
5 --> | 5 --> |
6 | 6 |
7 <link rel="import" href="../ct-last-updated.html"> | 7 <link rel="import" href="../ct-last-updated.html"> |
8 | 8 |
9 <script> | 9 <script> |
10 (function() { | 10 (function() { |
11 | 11 |
12 var assert = chai.assert; | 12 var assert = chai.assert; |
13 | 13 |
14 describe('ct-last-updated', function() { | 14 describe('ct-last-updated', function() { |
15 var lastUpdated; | 15 var lastUpdated; |
16 | 16 |
17 describe('Updated 5 minutes ago', function() { | 17 describe('Updated 5 minutes ago', function() { |
18 beforeEach(function(done) { | 18 beforeEach(function(done) { |
19 lastUpdated = document.createElement('ct-last-updated'); | 19 lastUpdated = document.createElement('ct-last-updated'); |
20 // Set the date to 5 minutes ago. | 20 // Set the date to 5 minutes ago. |
21 lastUpdated.date = new Date(Date.now() - (5 * 60 * 1000)); | 21 lastUpdated.date = new Date(Date.now() - (5 * 60 * 1000)); |
22 requestAnimationFrame(function() { done(); }); | 22 requestAnimationFrame(function() { done(); }); |
23 }); | 23 }); |
24 | 24 |
25 it('should have correct text', function() { | 25 it('should have correct text', function() { |
26 var expected = 'Updated 5 min ago @ ' + lastUpdated.date.getHours() + ':' + | 26 var expected = 'Updated 5 min ago @ ' + lastUpdated.date.getHours() + ':' + |
27 lastUpdated.date.getMinutes(); | 27 lastUpdated.date.getMinutes().toString().padLeft(2, '0'); |
ojan
2014/08/14 01:26:48
Can you modify this test to give repeatable result
| |
28 assert.include(lastUpdated.shadowRoot.innerHTML.trim(), expected); | 28 assert.include(lastUpdated.shadowRoot.innerHTML.trim(), expected); |
29 }); | 29 }); |
30 }); | 30 }); |
31 | 31 |
32 describe('No updated data', function() { | 32 describe('No updated data', function() { |
33 beforeEach(function(done) { | 33 beforeEach(function(done) { |
34 lastUpdated = document.createElement('ct-last-updated'); | 34 lastUpdated = document.createElement('ct-last-updated'); |
35 requestAnimationFrame(function() { done(); }); | 35 requestAnimationFrame(function() { done(); }); |
36 }); | 36 }); |
37 | 37 |
(...skipping 14 matching lines...) Expand all Loading... | |
52 var expected = '11:05'; | 52 var expected = '11:05'; |
53 assert.include(lastUpdated.shadowRoot.innerHTML.trim(), expected); | 53 assert.include(lastUpdated.shadowRoot.innerHTML.trim(), expected); |
54 }); | 54 }); |
55 }); | 55 }); |
56 | 56 |
57 }); | 57 }); |
58 | 58 |
59 })() | 59 })() |
60 | 60 |
61 </script> | 61 </script> |
OLD | NEW |