Chromium Code Reviews| 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 = {}; | |
|
calamity
2017/03/20 05:04:50
nit: rm obj creat.
tsergeant
2017/03/20 06:03:18
Done.
| |
| 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.editNode(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.editNode(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.editNode(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.editNode(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 |