| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 cr.define('md_history.history_card_test', function() { | 5 cr.define('md_history.history_card_test', function() { |
| 6 function registerTests() { | 6 function registerTests() { |
| 7 suite('history-card', function() { | 7 suite('history-card', function() { |
| 8 test('basic separator insertion', function(done) { | 8 var element; |
| 9 var element = document.createElement('history-card'); | 9 |
| 10 suiteSetup(function() { |
| 11 element = document.createElement('history-card'); |
| 10 element.historyItems = [ | 12 element.historyItems = [ |
| 11 {"time": "1000000000"}, | 13 {"time": "1000000000"}, |
| 12 {"time": "10000000"}, | 14 {"time": "10000000"}, |
| 13 {"time": "900000"} | 15 {"time": "900000"} |
| 14 ]; | 16 ]; |
| 17 }) |
| 18 |
| 19 test('basic separator insertion', function(done) { |
| 15 flush(function() { | 20 flush(function() { |
| 16 // Check that the correct number of time gaps are inserted. | 21 // Check that the correct number of time gaps are inserted. |
| 17 var spacers = | 22 var spacers = |
| 18 Polymer.dom(element.root).querySelectorAll('#time-gap-separator'); | 23 Polymer.dom(element.root).querySelectorAll('#time-gap-separator'); |
| 19 assertEquals(2, spacers.length); | 24 assertEquals(2, spacers.length); |
| 20 done(); | 25 done(); |
| 21 }); | 26 }); |
| 22 }); | 27 }); |
| 28 |
| 29 test('separator insertion when items change but item list length stays ' + |
| 30 'the same', function(done) { |
| 31 element.set('historyItems', [{"time": "900000"}, |
| 32 {"time": "900000"}, |
| 33 {"time": "900000"}]); |
| 34 |
| 35 flush(function() { |
| 36 var items = |
| 37 Polymer.dom(element.root).querySelectorAll('history-item'); |
| 38 var spacers = |
| 39 Polymer.dom(element.root).querySelectorAll('#time-gap-separator'); |
| 40 |
| 41 assertEquals('900000', items[0].timestamp_); |
| 42 assertEquals('900000', items[1].timestamp_); |
| 43 assertEquals('900000', items[2].timestamp_); |
| 44 |
| 45 // Note that the spacers aren't actually removed, are just set to: |
| 46 // display: none; |
| 47 for (var i = 0; i < spacers.length; i++) { |
| 48 assertEquals(spacers[i].style.display, 'none'); |
| 49 } |
| 50 done(); |
| 51 }); |
| 52 }); |
| 23 }); | 53 }); |
| 24 } | 54 } |
| 25 return { | 55 return { |
| 26 registerTests: registerTests | 56 registerTests: registerTests |
| 27 }; | 57 }; |
| 28 }); | 58 }); |
| OLD | NEW |