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

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

Issue 2745993002: MD Bookmarks: Update URL router to work in new data binding system (Closed)
Patch Set: calamity@ review 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/router_test.js
diff --git a/chrome/test/data/webui/md_bookmarks/router_test.js b/chrome/test/data/webui/md_bookmarks/router_test.js
new file mode 100644
index 0000000000000000000000000000000000000000..68eabe1c8799b1a0d2fa061c6cc9cbd286771396
--- /dev/null
+++ b/chrome/test/data/webui/md_bookmarks/router_test.js
@@ -0,0 +1,80 @@
+// 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-router>', function() {
+ var store;
+ var router;
+
+ function navigateTo(route) {
+ window.history.replaceState({}, '', route);
+ window.dispatchEvent(new CustomEvent('location-changed'));
+ }
+
+ setup(function() {
+ store = new bookmarks.TestStore({
+ selectedId: '1',
+ search: {
+ term: '',
+ },
+ });
+ bookmarks.Store.instance_ = store;
+
+ router = document.createElement('bookmarks-router');
+ replaceBody(router);
+ });
+
+ test('search updates from route', function() {
+ navigateTo('/?q=bleep');
+ assertEquals('start-search', store.lastAction.name);
+ assertEquals('bleep', store.lastAction.term);
+ });
+
+ test('selected folder updates from route', function() {
+ navigateTo('/?id=5');
+ assertEquals('select-folder', store.lastAction.name);
+ assertEquals('5', store.lastAction.id);
+ });
+
+ test('route updates from ID', function() {
+ store.data.selectedFolder = '6';
+ store.notifyObservers();
+
+ return Promise.resolve().then(function() {
+ assertEquals('chrome://bookmarks/?id=6', window.location.href);
+ });
+ });
+
+ test('route updates from search', function() {
+ store.data.search = {term: 'bloop'};
+ store.notifyObservers();
+
+ return Promise.resolve()
+ .then(function() {
+ assertEquals('chrome://bookmarks/?q=bloop', window.location.href);
+
+ // Ensure that the route doesn't change when the search finishes.
+ store.data.selectedFolder = null;
+ store.notifyObservers();
+ })
+ .then(function() {
+ assertEquals('chrome://bookmarks/?q=bloop', window.location.href);
+ });
+ });
+});
+
+suite('URL preload', function() {
+ test('loading a search URL performs a search', function(done) {
+ function verifySearch(query) {
+ assertEquals('testQuery', query);
+ done();
+ }
+
+ if (window.searchedQuery) {
+ verifySearch(window.searchedQuery);
+ return;
+ }
+
+ chrome.bookmarks.search = verifySearch;
+ });
+});
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/md_bookmarks_browsertest.js ('k') | chrome/test/data/webui/md_bookmarks/store_test.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698