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

Side by Side 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: Change initialization, add integration test 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 unified diff | Download patch
OLDNEW
(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-router>', function() {
6 var store;
7 var router;
8
9 function navigateTo(route) {
10 window.history.replaceState({}, '', route);
11 window.dispatchEvent(new CustomEvent('location-changed'));
12 }
13
14 setup(function() {
15 store = new bookmarks.TestStore({
16 selectedId: '1',
17 search: {
18 term: '',
19 },
20 });
21 bookmarks.Store.instance_ = store;
22
23 router = document.createElement('bookmarks-router');
24 replaceBody(router);
25 });
26
27 test('search updates from route', function() {
28 navigateTo('/?q=bleep');
29 assertEquals('start-search', store.lastAction.name);
30 assertEquals('bleep', store.lastAction.term);
31 });
32
33 test('selected folder updates from route', function() {
34 navigateTo('/?id=5');
35 assertEquals('select-folder', store.lastAction.name);
36 assertEquals('5', store.lastAction.id);
37 });
38
39 test('route updates from ID', function() {
40 store.data.selectedFolder = '6';
41 store.notifyObservers();
42
43 return Promise.resolve().then(function() {
44 assertEquals('chrome://bookmarks/?id=6', window.location.href);
45 });
46 });
47
48 test('route updates from search', function() {
49 store.data.search = {term: 'bloop'};
50 store.notifyObservers();
51
52 return Promise.resolve()
53 .then(function() {
54 assertEquals('chrome://bookmarks/?q=bloop', window.location.href);
55
56 // Ensure that the route doesn't change when the search finishes:
calamity 2017/03/20 06:34:28 nit: Too many dots.
tsergeant 2017/03/21 00:27:07 .......... :::Done::: ˙˙˙˙˙˙˙˙˙˙
57 store.data.selectedFolder = null;
58 store.notifyObservers();
59 })
60 .then(function() {
61 assertEquals('chrome://bookmarks/?q=bloop', window.location.href);
62 });
63 });
64 });
65
66 suite('URL preload', function() {
67 test('loading a search URL performs a search', function(done) {
68 function verifySearch(query) {
69 assertEquals('testQuery', query);
70 done();
71 }
72
73 if (window.searchedQuery) {
74 verifySearch(window.searchedQuery);
75 return;
76 }
77
78 chrome.bookmarks.search = verifySearch;
79 });
80 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698