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_item_test', function() { | 5 cr.define('md_history.history_item_test', function() { |
6 function registerTests() { | 6 function registerTests() { |
7 suite('history-item', function() { | 7 suite('history-item', function() { |
8 var element; | 8 var element; |
9 var TEST_HISTORY_RESULTS; | 9 var TEST_HISTORY_RESULTS; |
10 var SEARCH_HISTORY_RESULTS; | 10 var SEARCH_HISTORY_RESULTS; |
(...skipping 10 matching lines...) Expand all Loading... | |
21 ]; | 21 ]; |
22 | 22 |
23 SEARCH_HISTORY_RESULTS = [ | 23 SEARCH_HISTORY_RESULTS = [ |
24 createSearchEntry('2016-03-16', "http://www.google.com"), | 24 createSearchEntry('2016-03-16', "http://www.google.com"), |
25 createSearchEntry('2016-03-14', "http://calendar.google.com"), | 25 createSearchEntry('2016-03-14', "http://calendar.google.com"), |
26 createSearchEntry('2016-03-14', "http://mail.google.com") | 26 createSearchEntry('2016-03-14', "http://mail.google.com") |
27 ]; | 27 ]; |
28 }); | 28 }); |
29 | 29 |
30 test('basic separator insertion', function(done) { | 30 test('basic separator insertion', function(done) { |
31 element.addNewResults(TEST_HISTORY_RESULTS, ''); | 31 element.addNewResults(TEST_HISTORY_RESULTS); |
32 flush(function() { | 32 flush(function() { |
33 // Check that the correct number of time gaps are inserted. | 33 // Check that the correct number of time gaps are inserted. |
34 var items = | 34 var items = |
35 Polymer.dom(element.root).querySelectorAll('history-item'); | 35 Polymer.dom(element.root).querySelectorAll('history-item'); |
36 | 36 |
37 assertTrue(items[0].hasTimeGap); | 37 assertTrue(items[0].hasTimeGap); |
38 assertTrue(items[1].hasTimeGap); | 38 assertTrue(items[1].hasTimeGap); |
39 assertFalse(items[2].hasTimeGap); | 39 assertFalse(items[2].hasTimeGap); |
40 assertTrue(items[3].hasTimeGap); | 40 assertTrue(items[3].hasTimeGap); |
41 assertFalse(items[4].hasTimeGap); | 41 assertFalse(items[4].hasTimeGap); |
42 assertFalse(items[5].hasTimeGap); | 42 assertFalse(items[5].hasTimeGap); |
43 | 43 |
44 done(); | 44 done(); |
45 }); | 45 }); |
46 }); | 46 }); |
47 | 47 |
48 test('separator insertion for search', function(done) { | 48 test('separator insertion for search', function(done) { |
49 element.addNewResults(SEARCH_HISTORY_RESULTS, 'search'); | 49 element.addNewResults(SEARCH_HISTORY_RESULTS); |
50 element.searchedTerm = 'search'; | |
tsergeant
2016/05/13 03:41:06
Related to previous question, is searchedTerm expe
calamity
2016/05/18 01:41:52
Fixed this test.
| |
50 flush(function() { | 51 flush(function() { |
51 var items = | 52 var items = |
52 Polymer.dom(element.root).querySelectorAll('history-item'); | 53 Polymer.dom(element.root).querySelectorAll('history-item'); |
53 | 54 |
54 assertTrue(items[0].hasTimeGap); | 55 assertTrue(items[0].hasTimeGap); |
55 assertFalse(items[1].hasTimeGap); | 56 assertFalse(items[1].hasTimeGap); |
56 assertFalse(items[2].hasTimeGap); | 57 assertFalse(items[2].hasTimeGap); |
57 | 58 |
58 done(); | 59 done(); |
59 }); | 60 }); |
60 }); | 61 }); |
61 | 62 |
62 test('separator insertion after deletion', function(done) { | 63 test('separator insertion after deletion', function(done) { |
63 element.addNewResults(TEST_HISTORY_RESULTS, ''); | 64 element.addNewResults(TEST_HISTORY_RESULTS); |
64 flush(function() { | 65 flush(function() { |
65 var items = | 66 var items = |
66 Polymer.dom(element.root).querySelectorAll('history-item'); | 67 Polymer.dom(element.root).querySelectorAll('history-item'); |
67 | 68 |
68 element.set('historyData.3.selected', true); | 69 element.set('historyData.3.selected', true); |
69 items[3].onCheckboxSelected_(); | 70 items[3].onCheckboxSelected_(); |
70 | 71 |
71 element.removeDeletedHistory(1); | 72 element.removeDeletedHistory(1); |
72 assertEquals(element.historyData.length, 5); | 73 assertEquals(element.historyData.length, 5); |
73 | 74 |
74 // Checks that a new time gap separator has been inserted. | 75 // Checks that a new time gap separator has been inserted. |
75 assertTrue(items[2].hasTimeGap); | 76 assertTrue(items[2].hasTimeGap); |
76 | 77 |
77 element.set('historyData.3.selected', true); | 78 element.set('historyData.3.selected', true); |
78 items[3].onCheckboxSelected_(); | 79 items[3].onCheckboxSelected_(); |
79 element.removeDeletedHistory(1); | 80 element.removeDeletedHistory(1); |
80 | 81 |
81 // Checks time gap separator is removed. | 82 // Checks time gap separator is removed. |
82 assertFalse(items[2].hasTimeGap); | 83 assertFalse(items[2].hasTimeGap); |
83 done(); | 84 done(); |
84 }); | 85 }); |
85 }); | 86 }); |
86 | 87 |
87 teardown(function() { | 88 teardown(function() { |
88 element.historyData = []; | 89 element.historyData = []; |
90 element.searchedTerm = ''; | |
89 }); | 91 }); |
90 }); | 92 }); |
91 } | 93 } |
92 return { | 94 return { |
93 registerTests: registerTests | 95 registerTests: registerTests |
94 }; | 96 }; |
95 }); | 97 }); |
OLD | NEW |