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

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: Fix closure 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..490917f122397789e7c30b62fe6eba3050944c42
--- /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 = {};
calamity 2017/03/20 05:04:50 nit: rm obj creat.
tsergeant 2017/03/20 06:03:18 Done.
+
+ 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.editNode(item);
+
+ assertFalse(dialog.$.url.hidden);
+ });
+
+ test('editing a folder hides the url field', function() {
+ var folder = createFolder('0', []);
+ dialog.editNode(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.editNode(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.editNode(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);
+ });
+});

Powered by Google App Engine
This is Rietveld 408576698