Chromium Code Reviews| Index: chrome/test/data/webui/md_history/history_toolbar_test.js |
| diff --git a/chrome/test/data/webui/md_history/history_toolbar_test.js b/chrome/test/data/webui/md_history/history_toolbar_test.js |
| index 6e0cded808a621d55488a78309da20b80a090aea..814c32bb05de198c3293faf583327070b26527a4 100644 |
| --- a/chrome/test/data/webui/md_history/history_toolbar_test.js |
| +++ b/chrome/test/data/webui/md_history/history_toolbar_test.js |
| @@ -7,6 +7,7 @@ cr.define('md_history.history_toolbar_test', function() { |
| var TEST_HISTORY_RESULTS = [ |
| { |
| "dateRelativeDay": "Today - Wednesday, December 9, 2015", |
| + "title": "Google", |
| "url": "https://www.google.com" |
| } |
| ]; |
| @@ -22,7 +23,7 @@ cr.define('md_history.history_toolbar_test', function() { |
| }); |
| test('selecting checkbox causes toolbar to change', function(done) { |
| - element.addNewResults(TEST_HISTORY_RESULTS); |
| + element.addNewResults(TEST_HISTORY_RESULTS, ''); |
| flush(function() { |
| var item = element.$$('history-card').$$('history-item'); |
| @@ -47,7 +48,74 @@ cr.define('md_history.history_toolbar_test', function() { |
| }); |
| }); |
| + test('search term gathered correctly from toolbar', function(done) { |
| + registerMessageCallback('queryHistory', this, function (info) { |
| + assertEquals(info[0], 'Test'); |
| + done(); |
| + }); |
| + |
| + toolbar.onSearchTermSearch('Test'); |
| + }); |
| + |
| + test('search results display with correct item title', function(done) { |
|
tsergeant
2016/02/09 04:28:53
These next few tests should be moved to history_ca
hsampson
2016/02/11 02:46:26
Done.
|
| + element.addNewResults(TEST_HISTORY_RESULTS, 'Google'); |
| + |
| + flush(function() { |
| + var heading = |
| + element.$$('history-card').$$('#date-accessed').textContent; |
| + var title = element.$$('history-card').$$('history-item').$.title; |
| + |
| + // Check that the card title displays the search term somewhere. |
| + var index = heading.indexOf('Google'); |
| + assertTrue(index != -1); |
| + |
| + // Check that the search term is bolded correctly in the history-item. |
| + assertEquals(title.innerHTML, '<b>Google</b>'); |
| + done(); |
| + }); |
| + }); |
| + |
| + test('correct display message when no history available', function(done) { |
| + element.addNewResults([], ''); |
| + |
| + flush(function() { |
| + assertFalse(element.$['no-results'].hidden); |
| + assertTrue(element.$['no-search-results'].hidden); |
| + assertTrue(element.$['infinite-list'].hidden); |
| + |
| + element.addNewResults(TEST_HISTORY_RESULTS, ''); |
| + |
| + flush(function() { |
| + assertTrue(element.$['no-results'].hidden); |
| + assertTrue(element.$['no-search-results'].hidden); |
| + assertFalse(element.$['infinite-list'].hidden); |
| + done(); |
| + }); |
| + }); |
| + }); |
| + |
| + test('correct display message when no search results returned', |
| + function(done) { |
| + element.addNewResults([], 'Test'); |
| + |
| + flush(function() { |
| + assertFalse(element.$['no-search-results'].hidden); |
| + assertTrue(element.$['no-results'].hidden); |
| + assertTrue(element.$['infinite-list'].hidden); |
| + |
| + element.addNewResults(TEST_HISTORY_RESULTS, ''); |
| + |
| + flush(function() { |
| + assertTrue(element.$['no-results'].hidden); |
| + assertTrue(element.$['no-search-results'].hidden); |
| + assertFalse(element.$['infinite-list'].hidden); |
| + done(); |
| + }); |
| + }); |
| + }); |
| + |
| teardown(function() { |
| + element.historyDataByDay_ = []; |
| toolbar.count = 0; |
| }); |
| }); |