Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(609)

Delta Between Two Patch Sets: test/test_browser_search_view.js

Issue 9841044: Update the Charmworld store to use Api1 vs Api0
Left Patch Set: Update the Charmworld store to use Api1 vs Api0 Created 11 years, 10 months ago
Right Patch Set: Update the Charmworld store to use Api1 vs Api0 Created 11 years, 10 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « test/test_browser_editorial.js ('k') | test/test_charm_store.js » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
1 /* 1 /*
2 This file is part of the Juju GUI, which lets users view and manage Juju 2 This file is part of the Juju GUI, which lets users view and manage Juju
3 environments within a graphical interface (https://launchpad.net/juju-gui). 3 environments within a graphical interface (https://launchpad.net/juju-gui).
4 Copyright (C) 2012-2013 Canonical Ltd. 4 Copyright (C) 2012-2013 Canonical Ltd.
5 5
6 This program is free software: you can redistribute it and/or modify it under 6 This program is free software: you can redistribute it and/or modify it under
7 the terms of the GNU Affero General Public License version 3, as published by 7 the terms of the GNU Affero General Public License version 3, as published by
8 the Free Software Foundation. 8 the Free Software Foundation.
9 9
10 This program is distributed in the hope that it will be useful, but WITHOUT 10 This program is distributed in the hope that it will be useful, but WITHOUT
(...skipping 12 matching lines...) Expand all
23 var apiURL, 23 var apiURL,
24 container, 24 container,
25 view, 25 view,
26 Y; 26 Y;
27 27
28 before(function(done) { 28 before(function(done) {
29 Y = YUI(GlobalConfig).use( 29 Y = YUI(GlobalConfig).use(
30 'json', 30 'json',
31 'juju-charm-store', 31 'juju-charm-store',
32 'juju-tests-utils', 32 'juju-tests-utils',
33 'juju-models',
33 'node', 34 'node',
34 'node-event-simulate', 35 'node-event-simulate',
35 'subapp-browser-searchview', 36 'subapp-browser-searchview',
36 function(Y) { 37 function(Y) {
37 // Need the handlebars helper for the charm-token to render. 38 // Need the handlebars helper for the charm-token to render.
38 Y.Handlebars.registerHelper( 39 Y.Handlebars.registerHelper(
39 'charmFilePath', 40 'charmFilePath',
40 function(charmID, file) { 41 function(charmID, file) {
41 return '/path/to/charm/' + file; 42 return '/path/to/charm/' + file;
42 }); 43 });
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 hit += 1; 113 hit += 1;
113 }; 114 };
114 view.hideIndicator = function() { 115 view.hideIndicator = function() {
115 hit += 1; 116 hit += 1;
116 hit.should.equal(2); 117 hit.should.equal(2);
117 done(); 118 done();
118 }; 119 };
119 view.render(); 120 view.render();
120 }); 121 });
121 122
122
123 it('handles empty text for search', function() { 123 it('handles empty text for search', function() {
124 view.set('filters', {text: ''}); 124 view.set('filters', {text: ''});
125 view.render(); 125 view.render();
126 assert.equal('charms?text=', apiURL); 126 assert.equal('charms?text=', apiURL);
127 }); 127 });
128 128
129 it('clicking a charm navigates for fullscreen', function(done) { 129 it('clicking a charm navigates for fullscreen', function(done) {
130 view.render(); 130 view.render();
131 view.on('viewNavigate', function(ev) { 131 view.on('viewNavigate', function(ev) {
132 ev.halt(); 132 ev.halt();
133 assert(ev.change.charmID === 'foo/bar-2'); 133 assert(ev.change.charmID === 'foo/bar-2');
134 done(); 134 done();
135 }); 135 });
136 136
137 container.one('.charm-token').simulate('click'); 137 container.one('.charm-token').simulate('click');
138 }); 138 });
139 139
140 it('clicking a charm navigates for sidebar', function(done) { 140 it('clicking a charm navigates for sidebar', function(done) {
141 view.render(); 141 view.render();
142 view.on('viewNavigate', function(ev) { 142 view.on('viewNavigate', function(ev) {
143 ev.halt(); 143 ev.halt();
144 assert(ev.change.charmID === 'foo/bar-2'); 144 assert(ev.change.charmID === 'foo/bar-2');
145 done(); 145 done();
146 }); 146 });
147 147
148 container.one('.charm-token').simulate('click'); 148 container.one('.charm-token').simulate('click');
149 }); 149 });
150 150
151 it('tells listeners the cache has updated', function() {
152 view.on(view.EV_CACHE_UPDATED, function(ev) {
153 assert.isObject(ev.cache);
154 });
155 view.render();
156 });
157
158 it('uses passed in cache data if available', function() {
159 var search_called = false,
160 results = new Y.juju.models.BrowserCharmList();
161
162 view.get('store').search = function() {
163 search_called = true;
164 return results;
165 };
166 view.render(results);
167 assert.isFalse(search_called);
168
169 view.render();
170 assert.isTrue(search_called);
171 });
151 }); 172 });
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b