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

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

Issue 2808333004: MD Bookmarks: Improve test coverage for Actions and Routing (Closed)
Patch Set: Remove .only Created 3 years, 8 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
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/md_bookmarks_browsertest.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
index cd624b0b2018f07721eac6f28a9b33d7588318ca..fc8fcbb727ae737ac0c2fb772931648f44affda6 100644
--- a/chrome/test/data/webui/md_bookmarks/router_test.js
+++ b/chrome/test/data/webui/md_bookmarks/router_test.js
@@ -13,6 +13,7 @@ suite('<bookmarks-router>', function() {
setup(function() {
store = new bookmarks.TestStore({
+ nodes: testTree(createFolder('1', [createFolder('2', [])])),
selectedFolder: '1',
search: {
term: '',
@@ -31,17 +32,17 @@ suite('<bookmarks-router>', function() {
});
test('selected folder updates from route', function() {
- navigateTo('/?id=5');
+ navigateTo('/?id=2');
assertEquals('select-folder', store.lastAction.name);
- assertEquals('5', store.lastAction.id);
+ assertEquals('2', store.lastAction.id);
});
test('route updates from ID', function() {
- store.data.selectedFolder = '6';
+ store.data.selectedFolder = '2';
store.notifyObservers();
return Promise.resolve().then(function() {
- assertEquals('chrome://bookmarks/?id=6', window.location.href);
+ assertEquals('chrome://bookmarks/?id=2', window.location.href);
});
});
@@ -64,17 +65,55 @@ suite('<bookmarks-router>', function() {
});
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;
+ /**
+ * Reset the page state with a <bookmarks-app> and a clean Store, with the
+ * given |url| to trigger routing initialization code.
+ */
+ function setupWithUrl(url) {
+ PolymerTest.clearBody();
+ bookmarks.Store.instance_ = undefined;
+ window.history.replaceState({}, '', url);
+
+ chrome.bookmarks.getTree = function(callback) {
+ console.log('getTree');
+ console.log(window.location.href);
+ callback([
+ createFolder(
+ '0',
+ [
+ createFolder(
+ '1',
+ [
+ createFolder('11', []),
+ ]),
+ createFolder(
+ '2',
+ [
+ createItem('21'),
+ ]),
+ ]),
+ ]);
+ };
+
+ app = document.createElement('bookmarks-app');
+ document.body.appendChild(app);
+ }
+
+ test('loading a search URL performs a search', function() {
+ var lastQuery;
+ chrome.bookmarks.search = function(query) {
+ lastQuery = query;
+ return ['11'];
+ };
+
+ setupWithUrl('/?q=testQuery');
+ assertEquals('testQuery', lastQuery);
+ });
+
+ test('loading a folder URL selects that folder', function() {
+ setupWithUrl('/?id=2');
+ var state = bookmarks.Store.getInstance().data;
+ assertEquals('2', state.selectedFolder);
+ assertDeepEquals(['21'], bookmarks.util.getDisplayedList(state));
});
});
« no previous file with comments | « chrome/test/data/webui/md_bookmarks/md_bookmarks_browsertest.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698