| 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 /** @fileoverview Suite of tests for cr-toolbar-search-field. */ | 5 /** @fileoverview Suite of tests for cr-toolbar-search-field. */ |
| 6 cr.define('cr_toolbar_search_field', function() { | 6 cr.define('cr_toolbar_search_field', function() { |
| 7 function registerTests() { | 7 function registerTests() { |
| 8 suite('cr-toolbar-search-field', function() { | 8 suite('cr-toolbar-search-field', function() { |
| 9 /** @type {?CrToolbarSearchFieldElement} */ | 9 /** @type {?CrToolbarSearchFieldElement} */ |
| 10 var field = null; | 10 var field = null; |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 assertFalse(field.showingSearch); | 67 assertFalse(field.showingSearch); |
| 68 assertEquals('', field.getValue()); | 68 assertEquals('', field.getValue()); |
| 69 | 69 |
| 70 simulateSearch('query2'); | 70 simulateSearch('query2'); |
| 71 // Expecting identical query to be ignored. | 71 // Expecting identical query to be ignored. |
| 72 simulateSearch('query2'); | 72 simulateSearch('query2'); |
| 73 | 73 |
| 74 assertEquals(['query1', '', 'query2'].join(), searches.join()); | 74 assertEquals(['query1', '', 'query2'].join(), searches.join()); |
| 75 }); | 75 }); |
| 76 | 76 |
| 77 test('notifies on setValue', function() { |
| 78 MockInteractions.tap(field); |
| 79 field.setValue('foo'); |
| 80 field.setValue(''); |
| 81 field.setValue('bar'); |
| 82 // Expecting identical query to be ignored. |
| 83 field.setValue('bar'); |
| 84 field.setValue('baz'); |
| 85 assertEquals(['foo', '', 'bar', 'baz'].join(), searches.join()); |
| 86 }); |
| 87 |
| 77 test('blur does not close field when a search is active', function() { | 88 test('blur does not close field when a search is active', function() { |
| 78 MockInteractions.tap(field); | 89 MockInteractions.tap(field); |
| 79 simulateSearch('test'); | 90 simulateSearch('test'); |
| 80 MockInteractions.blur(field.$.searchInput); | 91 MockInteractions.blur(field.$.searchInput); |
| 81 | 92 |
| 82 assertTrue(field.showingSearch); | 93 assertTrue(field.showingSearch); |
| 83 }); | 94 }); |
| 84 }); | 95 }); |
| 85 } | 96 } |
| 86 | 97 |
| 87 return { | 98 return { |
| 88 registerTests: registerTests, | 99 registerTests: registerTests, |
| 89 }; | 100 }; |
| 90 }); | 101 }); |
| OLD | NEW |