LEFT | RIGHT |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 | 3 |
4 describe('search view', function() { | 4 describe('search view', function() { |
5 var apiURL, | 5 var apiURL, |
6 container, | 6 container, |
7 view, | 7 view, |
8 Y; | 8 Y; |
9 | 9 |
10 before(function(done) { | 10 before(function(done) { |
11 Y = YUI(GlobalConfig).use( | 11 Y = YUI(GlobalConfig).use( |
12 'json', | 12 'json', |
13 'juju-charm-store', | 13 'juju-charm-store', |
14 'node', | 14 'node', |
15 'subapp-browser-searchview', | 15 'subapp-browser-searchview', |
16 function(Y) { | 16 function(Y) { |
17 done(); | 17 done(); |
18 }); | 18 }); |
19 }); | 19 }); |
20 | 20 |
21 beforeEach(function() { // Mock out a dummy location for the Store used in vie
w instances. | 21 beforeEach(function() { |
| 22 // Mock out a dummy location for the Store used in view instances. |
22 window.juju_config = {charmworldURL: 'http://localhost'}; | 23 window.juju_config = {charmworldURL: 'http://localhost'}; |
23 container = Y.Node.create('<div id="container"></div>'); | 24 container = Y.Node.create('<div id="container"></div>'); |
24 Y.one('body').append(container); | 25 Y.one('body').append(container); |
25 view = new Y.juju.browser.views.BrowserSearchView({text: 'foo'}); | 26 view = new Y.juju.browser.views.BrowserSearchView({text: 'foo'}); |
26 // | 27 // |
27 // Create monkeypatched store to verify right method is called. | 28 // Create monkeypatched store to verify right method is called. |
28 apiURL = ''; | 29 apiURL = ''; |
29 var fakeStore = new Y.juju.Charmworld0({}); | 30 var fakeStore = new Y.juju.Charmworld0({}); |
30 var sampleData = { | 31 var sampleData = { |
31 result: [{ | 32 result: [{ |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
68 var charmText = Y.one('.yui3-charmtoken').one('.title').get('text'); | 69 var charmText = Y.one('.yui3-charmtoken').one('.title').get('text'); |
69 assert.equal(charmText.replace(/\s+/g, ''), 'bar'); | 70 assert.equal(charmText.replace(/\s+/g, ''), 'bar'); |
70 }); | 71 }); |
71 | 72 |
72 it('handles empty text for search', function() { | 73 it('handles empty text for search', function() { |
73 view.set('text', ''); | 74 view.set('text', ''); |
74 view.render(); | 75 view.render(); |
75 assert.equal('charms?text=', apiURL); | 76 assert.equal('charms?text=', apiURL); |
76 }); | 77 }); |
77 }); | 78 }); |
LEFT | RIGHT |