Chromium Code Reviews| 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 spacers; |
| 9 var element = document.createElement('history-card'); | 9 var element; |
| 10 var items; | |
|
calamity
2016/02/04 23:59:52
nit: remove spacers and items from here and just h
| |
| 11 | |
| 12 suiteSetup(function() { | |
| 13 element = document.createElement('history-card'); | |
| 10 element.historyItems = [ | 14 element.historyItems = [ |
| 11 {"time": "1000000000"}, | 15 {"time": "1000000000"}, |
| 12 {"time": "10000000"}, | 16 {"time": "10000000"}, |
| 13 {"time": "900000"} | 17 {"time": "900000"} |
| 14 ]; | 18 ]; |
| 19 }) | |
| 20 | |
| 21 test('basic separator insertion', function(done) { | |
| 15 flush(function() { | 22 flush(function() { |
| 16 // Check that the correct number of time gaps are inserted. | 23 // Check that the correct number of time gaps are inserted. |
| 17 var spacers = | 24 spacers = |
| 18 Polymer.dom(element.root).querySelectorAll('#time-gap-separator'); | 25 Polymer.dom(element.root).querySelectorAll('#time-gap-separator'); |
| 19 assertEquals(2, spacers.length); | 26 assertEquals(2, spacers.length); |
| 20 done(); | 27 done(); |
| 21 }); | 28 }); |
| 22 }); | 29 }); |
| 30 | |
| 31 test('separator insertion when items change but card stays the same', | |
|
calamity
2016/02/04 23:59:52
'but item list length stays the same'
| |
| 32 function(done) { | |
| 33 element.set('historyItems', [{"time": "900000"}, | |
| 34 {"time": "900000"}, | |
| 35 {"time": "900000"}]); | |
| 36 | |
| 37 flush(function() { | |
| 38 items = Polymer.dom(element.root).querySelectorAll('history-item'); | |
| 39 spacers = | |
| 40 Polymer.dom(element.root).querySelectorAll('#time-gap-separator'); | |
| 41 | |
| 42 assertEquals('900000', items[0].timestamp_); | |
| 43 assertEquals('900000', items[1].timestamp_); | |
| 44 assertEquals('900000', items[2].timestamp_); | |
| 45 | |
| 46 // Note that the spacers aren't actually removed, are just set to: | |
| 47 // display: none; | |
| 48 for (var i = 0; i < spacers.length; i++) { | |
| 49 assertEquals(spacers[i].style.display, 'none'); | |
| 50 } | |
| 51 done(); | |
| 52 }); | |
| 53 }); | |
| 54 | |
| 55 teardown(function() { | |
| 56 spacers = []; | |
|
calamity
2016/02/04 23:59:52
You should be able to remove this.
| |
| 57 }); | |
| 23 }); | 58 }); |
| 24 } | 59 } |
| 25 return { | 60 return { |
| 26 registerTests: registerTests | 61 registerTests: registerTests |
| 27 }; | 62 }; |
| 28 }); | 63 }); |
| OLD | NEW |