Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4328)

Unified Diff: chrome/test/data/webui/md_bookmarks/edit_dialog_test.js

Issue 2742583003: MD Bookmarks: Extract bookmark editing into a <bookmark-edit-dialog> element (Closed)
Patch Set: Rename event handlers Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/webui/md_bookmarks/edit_dialog_test.js
diff --git a/chrome/test/data/webui/md_bookmarks/edit_dialog_test.js b/chrome/test/data/webui/md_bookmarks/edit_dialog_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..5bc4269e2644db0b0473c9abcf9aa0d27cd83823
--- /dev/null
+++ b/chrome/test/data/webui/md_bookmarks/edit_dialog_test.js
@@ -0,0 +1,58 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+suite('<bookmarks-edit-dialog>', function() {
+ var dialog;
+ var lastUpdate;
+
+ suiteSetup(function() {
+ chrome.bookmarks.update = function(id, edit) {
+ lastUpdate.id = id;
+ lastUpdate.edit = edit;
+ }
+ });
+
+ setup(function() {
+ lastUpdate = {};
+ dialog = document.createElement('bookmarks-edit-dialog');
+ replaceBody(dialog);
+ });
+
+ test('editing an item shows the url field', function() {
+ var item = createItem('0');
+ dialog.showEditDialog(item);
+
+ assertFalse(dialog.$.url.hidden);
+ });
+
+ test('editing a folder hides the url field', function() {
+ var folder = createFolder('0', []);
+ dialog.showEditDialog(folder);
+
+ assertTrue(dialog.$.url.hidden);
+ });
+
+ test('editing passes the correct details to the update', function() {
+ // Editing an item without changing anything.
+ var item = createItem('1', {url: 'www.website.com', title: 'website'});
+ dialog.showEditDialog(item);
+
+ MockInteractions.tap(dialog.$.saveButton);
+
+ assertEquals(item.id, lastUpdate.id);
+ assertEquals(item.url, lastUpdate.edit.url);
+ assertEquals(item.title, lastUpdate.edit.title);
+
+ // Editing a folder, changing the title.
+ var folder = createFolder('2', [], {title: 'Cool Sites'});
+ dialog.showEditDialog(folder);
+ dialog.titleValue_ = 'Awesome websites';
+
+ MockInteractions.tap(dialog.$.saveButton);
+
+ assertEquals(folder.id, lastUpdate.id);
+ assertEquals(undefined, lastUpdate.edit.url);
+ assertEquals('Awesome websites', lastUpdate.edit.title);
+ });
+});
« no previous file with comments | « chrome/browser/ui/webui/md_bookmarks/md_bookmarks_ui.cc ('k') | chrome/test/data/webui/md_bookmarks/list_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698