| 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 suite('<bookmarks-item>', function() { | 5 suite('<bookmarks-item>', function() { |
| 6 var item; | 6 var item; |
| 7 var store; |
| 7 var TEST_ITEM = createItem('0'); | 8 var TEST_ITEM = createItem('0'); |
| 8 | 9 |
| 9 setup(function() { | 10 setup(function() { |
| 11 store = new bookmarks.TestStore({ |
| 12 nodes: { |
| 13 '0': createItem('0'), |
| 14 }, |
| 15 }); |
| 16 bookmarks.Store.instance_ = store; |
| 17 |
| 10 item = document.createElement('bookmarks-item'); | 18 item = document.createElement('bookmarks-item'); |
| 19 item.itemId = '0'; |
| 11 replaceBody(item); | 20 replaceBody(item); |
| 12 item.item = TEST_ITEM; | |
| 13 }); | 21 }); |
| 14 | 22 |
| 15 test('changing the url changes the favicon', function() { | 23 test('changing the url changes the favicon', function() { |
| 16 var favicon = item.$.icon.style.backgroundImage; | 24 var favicon = item.$.icon.style.backgroundImage; |
| 17 item.set('item.url', 'http://www.mail.google.com'); | 25 store.data.nodes['0'] = createItem('0', {url: 'https://mail.google.com'}); |
| 26 store.notifyObservers(); |
| 18 assertNotEquals(favicon, item.$.icon.style.backgroundImage); | 27 assertNotEquals(favicon, item.$.icon.style.backgroundImage); |
| 19 }); | 28 }); |
| 20 | 29 |
| 21 test('changing isFolder_ hides/unhides the folder/icon', function() { | 30 test('changing to folder hides/unhides the folder/icon', function() { |
| 22 item.isFolder_ = true; | 31 // Starts test as an item. |
| 32 assertTrue(item.$['folder-icon'].hidden); |
| 33 assertFalse(item.$.icon.hidden); |
| 34 |
| 35 // Change to a folder. |
| 36 store.data.nodes['0'] = createFolder('0', []); |
| 37 store.notifyObservers(); |
| 38 |
| 23 assertFalse(item.$['folder-icon'].hidden); | 39 assertFalse(item.$['folder-icon'].hidden); |
| 24 assertTrue(item.$.icon.hidden); | 40 assertTrue(item.$.icon.hidden); |
| 25 | |
| 26 item.isFolder_ = false; | |
| 27 assertTrue(item.$['folder-icon'].hidden); | |
| 28 assertFalse(item.$.icon.hidden); | |
| 29 }); | |
| 30 | |
| 31 test('pressing the buttons fires the right event', function() { | |
| 32 var counter = [0, 0, 0]; | |
| 33 document.addEventListener('select-item', function(e) { | |
| 34 if (e.detail.range) | |
| 35 counter[0]++; | |
| 36 else if (e.detail.add) | |
| 37 counter[1]++; | |
| 38 else | |
| 39 counter[2]++; | |
| 40 }); | |
| 41 | |
| 42 customClick(item); | |
| 43 assertDeepEquals([0, 0, 1], counter); | |
| 44 | |
| 45 customClick(item, {shiftKey: true}); | |
| 46 assertDeepEquals([1, 0, 1], counter); | |
| 47 | |
| 48 customClick(item, {ctrlKey: true}); | |
| 49 assertDeepEquals([1, 1, 1], counter); | |
| 50 | |
| 51 customClick(item, {shiftKey: true, ctrlKey: true}); | |
| 52 assertDeepEquals([2, 1, 1], counter); | |
| 53 }); | 41 }); |
| 54 }); | 42 }); |
| OLD | NEW |