| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 suite('<site-data>', function() { | 5 suite('<site-data>', function() { |
| 6 /** @type {SiteDataElement} */ | 6 /** @type {SiteDataElement} */ |
| 7 var siteData; | 7 var siteData; |
| 8 | 8 |
| 9 /** @type {TestSiteSettingsPrefsBrowserProxy} */ | 9 /** @type {TestSiteSettingsPrefsBrowserProxy} */ |
| 10 var testBrowserProxy; | 10 var testBrowserProxy; |
| 11 | 11 |
| 12 setup(function() { | 12 setup(function() { |
| 13 testBrowserProxy = new TestSiteSettingsPrefsBrowserProxy; | 13 testBrowserProxy = new TestSiteSettingsPrefsBrowserProxy; |
| 14 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = testBrowserProxy; | 14 settings.SiteSettingsPrefsBrowserProxyImpl.instance_ = testBrowserProxy; |
| 15 siteData = document.createElement('site-data'); | 15 siteData = document.createElement('site-data'); |
| 16 }); | 16 }); |
| 17 | 17 |
| 18 test('tapping remove button (trash can) calls remove on origin', function() { | 18 test('tapping remove button (trash can) calls remove on origin', function() { |
| 19 var GOOGLE_ID = '1'; | 19 var GOOGLE_ID = '1'; |
| 20 siteData.sites = [{site: 'Google', id: GOOGLE_ID, localData: 'Cookiez!'}]; | 20 siteData.sites = [{site: 'Google', id: GOOGLE_ID, localData: 'Cookiez!'}]; |
| 21 Polymer.dom.flush(); | 21 Polymer.dom.flush(); |
| 22 | 22 |
| 23 MockInteractions.tap(siteData.$$('.remove-site')); | 23 MockInteractions.tap(siteData.$$('.remove-site')); |
| 24 | 24 |
| 25 return testBrowserProxy.whenCalled('removeCookie').then(function(path) { | 25 return testBrowserProxy.whenCalled('removeCookie').then(function(path) { |
| 26 assertEquals(GOOGLE_ID, path); | 26 assertEquals(GOOGLE_ID, path); |
| 27 }); | 27 }); |
| 28 }); | 28 }); |
| 29 |
| 30 test('remove button hidden when no search results', function() { |
| 31 siteData.sites = [ |
| 32 {site: 'Hello', id: '1', localData: 'Cookiez!'}, |
| 33 {site: 'World', id: '2', localData: 'Cookiez!'}, |
| 34 ]; |
| 35 |
| 36 Polymer.dom.flush(); |
| 37 assertEquals( |
| 38 siteData.sites.length, |
| 39 siteData.shadowRoot.querySelectorAll('.list-item').length); |
| 40 |
| 41 // Expecting one result, so the button should be shown. |
| 42 siteData.$.filter.dispatchEvent( |
| 43 new CustomEvent('search-changed', {detail: 'Hello'})); |
| 44 Polymer.dom.flush(); |
| 45 assertEquals( |
| 46 1, siteData.shadowRoot.querySelectorAll('.list-item').length); |
| 47 assertFalse(siteData.$.removeShowingSites.hidden); |
| 48 |
| 49 // Expecting no results, so the button should be hidden. |
| 50 siteData.$.filter.dispatchEvent( |
| 51 new CustomEvent('search-changed', {detail: 'foo'})); |
| 52 Polymer.dom.flush(); |
| 53 assertEquals( |
| 54 0, siteData.shadowRoot.querySelectorAll('.list-item').length); |
| 55 assertTrue(siteData.$.removeShowingSites.hidden); |
| 56 }); |
| 29 }); | 57 }); |
| OLD | NEW |