OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 suite('<bookmarks-edit-dialog>', function() { |
| 6 var dialog; |
| 7 var lastUpdate; |
| 8 |
| 9 suiteSetup(function() { |
| 10 chrome.bookmarks.update = function(id, edit) { |
| 11 lastUpdate.id = id; |
| 12 lastUpdate.edit = edit; |
| 13 } |
| 14 }); |
| 15 |
| 16 setup(function() { |
| 17 lastUpdate = {}; |
| 18 dialog = document.createElement('bookmarks-edit-dialog'); |
| 19 replaceBody(dialog); |
| 20 }); |
| 21 |
| 22 test('editing an item shows the url field', function() { |
| 23 var item = createItem('0'); |
| 24 dialog.showEditDialog(item); |
| 25 |
| 26 assertFalse(dialog.$.url.hidden); |
| 27 }); |
| 28 |
| 29 test('editing a folder hides the url field', function() { |
| 30 var folder = createFolder('0', []); |
| 31 dialog.showEditDialog(folder); |
| 32 |
| 33 assertTrue(dialog.$.url.hidden); |
| 34 }); |
| 35 |
| 36 test('editing passes the correct details to the update', function() { |
| 37 // Editing an item without changing anything. |
| 38 var item = createItem('1', {url: 'www.website.com', title: 'website'}); |
| 39 dialog.showEditDialog(item); |
| 40 |
| 41 MockInteractions.tap(dialog.$.saveButton); |
| 42 |
| 43 assertEquals(item.id, lastUpdate.id); |
| 44 assertEquals(item.url, lastUpdate.edit.url); |
| 45 assertEquals(item.title, lastUpdate.edit.title); |
| 46 |
| 47 // Editing a folder, changing the title. |
| 48 var folder = createFolder('2', [], {title: 'Cool Sites'}); |
| 49 dialog.showEditDialog(folder); |
| 50 dialog.titleValue_ = 'Awesome websites'; |
| 51 |
| 52 MockInteractions.tap(dialog.$.saveButton); |
| 53 |
| 54 assertEquals(folder.id, lastUpdate.id); |
| 55 assertEquals(undefined, lastUpdate.edit.url); |
| 56 assertEquals('Awesome websites', lastUpdate.edit.title); |
| 57 }); |
| 58 }); |
OLD | NEW |