| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 cr.define('md_history.history_card_test', function() { | |
| 6 function registerTests() { | |
| 7 suite('history-card', function() { | |
| 8 var element; | |
| 9 | |
| 10 suiteSetup(function() { | |
| 11 element = document.createElement('history-card'); | |
| 12 element.historyItems = [ | |
| 13 {"time": "1000000000"}, | |
| 14 {"time": "10000000"}, | |
| 15 {"time": "900000"} | |
| 16 ]; | |
| 17 }) | |
| 18 | |
| 19 test('basic separator insertion', function(done) { | |
| 20 flush(function() { | |
| 21 // Check that the correct number of time gaps are inserted. | |
| 22 var spacers = | |
| 23 Polymer.dom(element.root).querySelectorAll('#time-gap-separator'); | |
| 24 assertEquals(2, spacers.length); | |
| 25 done(); | |
| 26 }); | |
| 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 }); | |
| 53 }); | |
| 54 } | |
| 55 return { | |
| 56 registerTests: registerTests | |
| 57 }; | |
| 58 }); | |
| OLD | NEW |