| 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-list>', function() { | 5 suite('<bookmarks-list>', function() { |
| 6 var list; | 6 var list; |
| 7 var store; | 7 var store; |
| 8 | 8 |
| 9 setup(function() { | 9 setup(function() { |
| 10 store = new bookmarks.TestStore({ | 10 store = new bookmarks.TestStore({ |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 list.$.editBookmark.showModal(); | 58 list.$.editBookmark.showModal(); |
| 59 MockInteractions.tap(list.$.saveButton); | 59 MockInteractions.tap(list.$.saveButton); |
| 60 }); | 60 }); |
| 61 | 61 |
| 62 test('renders correct <bookmark-item> elements', function() { | 62 test('renders correct <bookmark-item> elements', function() { |
| 63 var items = list.root.querySelectorAll('bookmarks-item'); | 63 var items = list.root.querySelectorAll('bookmarks-item'); |
| 64 var ids = Array.from(items).map((item) => item.itemId); | 64 var ids = Array.from(items).map((item) => item.itemId); |
| 65 | 65 |
| 66 assertDeepEquals(['1', '3', '5', '7'], ids); | 66 assertDeepEquals(['1', '3', '5', '7'], ids); |
| 67 }); | 67 }); |
| 68 |
| 69 test('selects individual items', function() { |
| 70 var items = list.root.querySelectorAll('bookmarks-item'); |
| 71 |
| 72 customClick(items[0]); |
| 73 var expected = { |
| 74 name: 'select-items', |
| 75 add: false, |
| 76 anchor: '1', |
| 77 items: ['1'], |
| 78 }; |
| 79 assertDeepEquals(expected, store.lastAction); |
| 80 |
| 81 customClick(items[2], {ctrlKey: true}); |
| 82 expected.add = true; |
| 83 expected.anchor = '5'; |
| 84 expected.items = ['5']; |
| 85 assertDeepEquals(expected, store.lastAction); |
| 86 }); |
| 87 |
| 88 test('shift-selects multiple items', function() { |
| 89 var items = list.root.querySelectorAll('bookmarks-item'); |
| 90 store.data.selection.anchor = '1'; |
| 91 |
| 92 customClick(items[2], {shiftKey: true}); |
| 93 |
| 94 assertEquals('select-items', store.lastAction.name); |
| 95 assertFalse(store.lastAction.add); |
| 96 assertEquals('5', store.lastAction.anchor); |
| 97 assertDeepEquals(['1', '3', '5'], store.lastAction.items); |
| 98 }); |
| 99 |
| 100 test('selects the item when the anchor is missing', function() { |
| 101 var items = list.root.querySelectorAll('bookmarks-item'); |
| 102 // Anchor hasn't been set yet: |
| 103 store.data.selection.anchor = null; |
| 104 |
| 105 customClick(items[0], {shiftKey: true}); |
| 106 assertEquals('1', store.lastAction.anchor); |
| 107 assertDeepEquals(['1'], store.lastAction.items); |
| 108 |
| 109 // Anchor item doesn't exist: |
| 110 store.data.selection.anchor = '42'; |
| 111 |
| 112 customClick(items[1], {shiftKey: true}); |
| 113 |
| 114 assertEquals('3', store.lastAction.anchor); |
| 115 assertDeepEquals(['3'], store.lastAction.items); |
| 116 }); |
| 68 }); | 117 }); |
| OLD | NEW |