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

Side by Side Diff: test/test_browser_charm_details.js

Issue 13273047: Rename BrowserCharm model to just Charm
Patch Set: Rename BrowserCharm model to just Charm Created 11 years, 7 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:
View unified diff | Download patch
« no previous file with comments | « app/widgets/charm-token.js ('k') | test/test_browser_search_view.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 73
74 after(function() { 74 after(function() {
75 cleanIconHelper(); 75 cleanIconHelper();
76 }); 76 });
77 77
78 it('renders for inspector mode correctly', function() { 78 it('renders for inspector mode correctly', function() {
79 var data = utils.loadFixture('data/browsercharm.json', true); 79 var data = utils.loadFixture('data/browsercharm.json', true);
80 // We don't want any files so we don't have to mock/load them. 80 // We don't want any files so we don't have to mock/load them.
81 data.charm.files = []; 81 data.charm.files = [];
82 view = new CharmView({ 82 view = new CharmView({
83 charm: new models.BrowserCharm(data.charm), 83 charm: new models.Charm(data.charm),
84 container: utils.makeContainer(), 84 container: utils.makeContainer(),
85 forInspector: true 85 forInspector: true
86 }); 86 });
87 87
88 view.render(); 88 view.render();
89 assert.isNull(view.get('container').one('.heading')); 89 assert.isNull(view.get('container').one('.heading'));
90 // There is no 'related charms' tab to display. 90 // There is no 'related charms' tab to display.
91 assert.equal(view.get('container').all('.bws-related-charms').size(), 0); 91 assert.equal(view.get('container').all('.bws-related-charms').size(), 0);
92 }); 92 });
93 93
94 // Return the charm heading node included in the charm detail view. 94 // Return the charm heading node included in the charm detail view.
95 var makeHeading = function(is_subordinate) { 95 var makeHeading = function(is_subordinate) {
96 var data = utils.loadFixture('data/browsercharm.json', true); 96 var data = utils.loadFixture('data/browsercharm.json', true);
97 // We don't want any files so we don't have to mock/load them. 97 // We don't want any files so we don't have to mock/load them.
98 data.charm.files = []; 98 data.charm.files = [];
99 data.charm.is_subordinate = is_subordinate; 99 data.charm.is_subordinate = is_subordinate;
100 view = new CharmView({ 100 view = new CharmView({
101 charm: new models.BrowserCharm(data.charm), 101 charm: new models.Charm(data.charm),
102 container: utils.makeContainer() 102 container: utils.makeContainer()
103 }); 103 });
104 view.render(); 104 view.render();
105 var heading = view.get('container').one('.heading'); 105 var heading = view.get('container').one('.heading');
106 assert.isNotNull(heading); 106 assert.isNotNull(heading);
107 return heading; 107 return heading;
108 }; 108 };
109 109
110 it('avoids showing the subordinate message for non-subordinate charms', 110 it('avoids showing the subordinate message for non-subordinate charms',
111 function() { 111 function() {
112 var heading = makeHeading(false); 112 var heading = makeHeading(false);
113 assert.notInclude(heading.getContent(), 'Subordinate charm'); 113 assert.notInclude(heading.getContent(), 'Subordinate charm');
114 }); 114 });
115 115
116 it('shows the subordinate message if the charm is a subordinate', 116 it('shows the subordinate message if the charm is a subordinate',
117 function() { 117 function() {
118 var heading = makeHeading(true); 118 var heading = makeHeading(true);
119 assert.include(heading.getContent(), 'Subordinate charm'); 119 assert.include(heading.getContent(), 'Subordinate charm');
120 }); 120 });
121 121
122 it('renders local charms for inspector mode correctly', function() { 122 it('renders local charms for inspector mode correctly', function() {
123 var data = utils.loadFixture('data/browsercharm.json', true); 123 var data = utils.loadFixture('data/browsercharm.json', true);
124 // We don't want any files so we don't have to mock/load them. 124 // We don't want any files so we don't have to mock/load them.
125 data.charm.files = []; 125 data.charm.files = [];
126 data.charm.url = 'local:precise/apache2-10'; 126 data.charm.url = 'local:precise/apache2-10';
127 var charm = new models.BrowserCharm(data.charm); 127 var charm = new models.Charm(data.charm);
128 charm.set('scheme', 'local'); 128 charm.set('scheme', 'local');
129 view = new CharmView({ 129 view = new CharmView({
130 charm: charm, 130 charm: charm,
131 container: utils.makeContainer(), 131 container: utils.makeContainer(),
132 forInspector: true 132 forInspector: true
133 }); 133 });
134 134
135 view.render(); 135 view.render();
136 assert.isNull(view.get('container').one('.heading')); 136 assert.isNull(view.get('container').one('.heading'));
137 assert.isNull(view.get('container').one('#bws-readme')); 137 assert.isNull(view.get('container').one('#bws-readme'));
(...skipping 11 matching lines...) Expand all
149 response: { 149 response: {
150 results: [{ 150 results: [{
151 responseText: 'README content.' 151 responseText: 'README content.'
152 }] 152 }]
153 } 153 }
154 }); 154 });
155 } 155 }
156 }); 156 });
157 157
158 view = new CharmView({ 158 view = new CharmView({
159 charm: new models.BrowserCharm({ 159 charm: new models.Charm({
160 files: [ 160 files: [
161 'hooks/install', 161 'hooks/install',
162 'readme.rst' 162 'readme.rst'
163 ], 163 ],
164 id: 'precise/ceph-9', 164 id: 'precise/ceph-9',
165 code_source: { location: 'lp:~foo'} 165 code_source: { location: 'lp:~foo'}
166 }), 166 }),
167 container: utils.makeContainer(), 167 container: utils.makeContainer(),
168 store: fakeStore 168 store: fakeStore
169 }); 169 });
170 view.render(); 170 view.render();
171 var links = container.all('#sharing a'); 171 var links = container.all('#sharing a');
172 assert.equal(links.size(), 3); 172 assert.equal(links.size(), 3);
173 }); 173 });
174 174
175 it('should be able to locate a readme file', function() { 175 it('should be able to locate a readme file', function() {
176 view = new CharmView({ 176 view = new CharmView({
177 charm: new models.BrowserCharm({ 177 charm: new models.Charm({
178 files: [ 178 files: [
179 'hooks/install', 179 'hooks/install',
180 'readme.rst' 180 'readme.rst'
181 ], 181 ],
182 id: 'precise/ceph-9', 182 id: 'precise/ceph-9',
183 code_source: { location: 'lp:~foo' } 183 code_source: { location: 'lp:~foo' }
184 }) 184 })
185 }); 185 });
186 view._locateReadme().should.eql('readme.rst'); 186 view._locateReadme().should.eql('readme.rst');
187 187
188 // Matches for caps as well 188 // Matches for caps as well
189 view.get('charm').set('files', [ 189 view.get('charm').set('files', [
190 'hooks/install', 190 'hooks/install',
191 'README.md' 191 'README.md'
192 ]); 192 ]);
193 view._locateReadme().should.eql('README.md'); 193 view._locateReadme().should.eql('README.md');
194 }); 194 });
195 195
196 it('can generate source and revno links from its charm', function() { 196 it('can generate source and revno links from its charm', function() {
197 view = new CharmView({ 197 view = new CharmView({
198 charm: new models.BrowserCharm({ 198 charm: new models.Charm({
199 files: [ 199 files: [
200 'hooks/install', 200 'hooks/install',
201 'readme.rst' 201 'readme.rst'
202 ], 202 ],
203 id: 'precise/ceph-9', 203 id: 'precise/ceph-9',
204 code_source: { location: 'lp:~foo'} 204 code_source: { location: 'lp:~foo'}
205 }) 205 })
206 }); 206 });
207 var url = view._getSourceLink(); 207 var url = view._getSourceLink();
208 assert.equal('http://bazaar.launchpad.net/~foo/files', url); 208 assert.equal('http://bazaar.launchpad.net/~foo/files', url);
209 assert.equal( 209 assert.equal(
210 'http://bazaar.launchpad.net/~foo/revision/1', 210 'http://bazaar.launchpad.net/~foo/revision/1',
211 view._getRevnoLink(url, 1)); 211 view._getRevnoLink(url, 1));
212 }); 212 });
213 213
214 it('can generate useful display data for commits', function() { 214 it('can generate useful display data for commits', function() {
215 view = new CharmView({ 215 view = new CharmView({
216 charm: new models.BrowserCharm({ 216 charm: new models.Charm({
217 files: [ 217 files: [
218 'hooks/install', 218 'hooks/install',
219 'readme.rst' 219 'readme.rst'
220 ], 220 ],
221 id: 'precise/ceph-9', 221 id: 'precise/ceph-9',
222 code_source: { 222 code_source: {
223 location: 'lp:~foo' 223 location: 'lp:~foo'
224 } 224 }
225 }) 225 })
226 }); 226 });
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 results: [{ 264 results: [{
265 responseText: 'README content.' 265 responseText: 'README content.'
266 }] 266 }]
267 } 267 }
268 }); 268 });
269 } 269 }
270 }); 270 });
271 271
272 view = new CharmView({ 272 view = new CharmView({
273 activeTab: '#bws-readme', 273 activeTab: '#bws-readme',
274 charm: new models.BrowserCharm({ 274 charm: new models.Charm({
275 files: [ 275 files: [
276 'hooks/install', 276 'hooks/install',
277 'readme.rst' 277 'readme.rst'
278 ], 278 ],
279 id: 'precise/ceph-9', 279 id: 'precise/ceph-9',
280 code_source: { location: 'lp:~foo'} 280 code_source: { location: 'lp:~foo'}
281 }), 281 }),
282 container: utils.makeContainer(), 282 container: utils.makeContainer(),
283 store: fakeStore 283 store: fakeStore
284 }); 284 });
285 285
286 view.render(); 286 view.render();
287 287
288 Y.one('#bws-readme').get('text').should.eql('README content.'); 288 Y.one('#bws-readme').get('text').should.eql('README content.');
289 }); 289 });
290 290
291 // EVENTS 291 // EVENTS
292 it('should catch when the add control is clicked', function(done) { 292 it('should catch when the add control is clicked', function(done) {
293 view = new CharmView({ 293 view = new CharmView({
294 activeTab: '#bws-readme', 294 activeTab: '#bws-readme',
295 charm: new models.BrowserCharm({ 295 charm: new models.Charm({
296 files: [ 296 files: [
297 'hooks/install' 297 'hooks/install'
298 ], 298 ],
299 id: 'precise/ceph-9', 299 id: 'precise/ceph-9',
300 code_source: { location: 'lp:~foo' } 300 code_source: { location: 'lp:~foo' }
301 }), 301 }),
302 container: utils.makeContainer() 302 container: utils.makeContainer()
303 }); 303 });
304 304
305 // Hook up to the callback for the click event. 305 // Hook up to the callback for the click event.
306 view._addCharmEnvironment = function(ev) { 306 view._addCharmEnvironment = function(ev) {
307 ev.halt(); 307 ev.halt();
308 Y.one('#bws-readme h3').get('text').should.eql('Charm has no README'); 308 Y.one('#bws-readme h3').get('text').should.eql('Charm has no README');
309 done(); 309 done();
310 }; 310 };
311 311
312 view.render(); 312 view.render();
313 node.one('.charm .add').simulate('click'); 313 node.one('.charm .add').simulate('click');
314 }); 314 });
315 315
316 316
317 it('_addCharmEnvironment displays the config panel', function(done) { 317 it('_addCharmEnvironment displays the config panel', function(done) {
318 var fakeStore = new Y.juju.charmworld.APIv2({}); 318 var fakeStore = new Y.juju.charmworld.APIv2({});
319 fakeStore.iconpath = function() { 319 fakeStore.iconpath = function() {
320 return 'charm icon url'; 320 return 'charm icon url';
321 }; 321 };
322 view = new CharmView({ 322 view = new CharmView({
323 charm: new models.BrowserCharm({ 323 charm: new models.Charm({
324 files: [ 324 files: [
325 'hooks/install' 325 'hooks/install'
326 ], 326 ],
327 id: 'precise/ceph-9', 327 id: 'precise/ceph-9',
328 url: 'cs:precise/ceph-9', 328 url: 'cs:precise/ceph-9',
329 code_source: { location: 'lp:~foo' }, 329 code_source: { location: 'lp:~foo' },
330 options: { 330 options: {
331 configName: 'test' 331 configName: 'test'
332 } 332 }
333 }), 333 }),
(...skipping 19 matching lines...) Expand all
353 response: { 353 response: {
354 results: [{ 354 results: [{
355 responseText: 'install hook content.' 355 responseText: 'install hook content.'
356 }] 356 }]
357 } 357 }
358 }); 358 });
359 } 359 }
360 }); 360 });
361 361
362 view = new CharmView({ 362 view = new CharmView({
363 charm: new models.BrowserCharm({ 363 charm: new models.Charm({
364 files: [ 364 files: [
365 'hooks/install', 365 'hooks/install',
366 'readme.rst' 366 'readme.rst'
367 ], 367 ],
368 id: 'precise/ceph-9', 368 id: 'precise/ceph-9',
369 code_source: { location: 'lp:~foo' } 369 code_source: { location: 'lp:~foo' }
370 }), 370 }),
371 container: utils.makeContainer(), 371 container: utils.makeContainer(),
372 store: fakeStore 372 store: fakeStore
373 }); 373 });
(...skipping 23 matching lines...) Expand all
397 '=============' 397 '============='
398 ].join('\n') 398 ].join('\n')
399 }] 399 }]
400 } 400 }
401 }); 401 });
402 } 402 }
403 }); 403 });
404 404
405 view = new CharmView({ 405 view = new CharmView({
406 activeTab: '#bws-readme', 406 activeTab: '#bws-readme',
407 charm: new models.BrowserCharm({ 407 charm: new models.Charm({
408 files: [ 408 files: [
409 'readme.md' 409 'readme.md'
410 ], 410 ],
411 id: 'precise/ceph-9', 411 id: 'precise/ceph-9',
412 code_source: { location: 'lp:~foo' } 412 code_source: { location: 'lp:~foo' }
413 }), 413 }),
414 container: utils.makeContainer(), 414 container: utils.makeContainer(),
415 store: fakeStore 415 store: fakeStore
416 }); 416 });
417 417
418 view.render(); 418 view.render();
419 Y.one('#bws-readme').get('innerHTML').should.eql( 419 Y.one('#bws-readme').get('innerHTML').should.eql(
420 '<h1>README Header</h1>'); 420 '<h1>README Header</h1>');
421 }); 421 });
422 422
423 it('should display the config data in the config tab', function() { 423 it('should display the config data in the config tab', function() {
424 view = new CharmView({ 424 view = new CharmView({
425 charm: new models.BrowserCharm({ 425 charm: new models.Charm({
426 files: [], 426 files: [],
427 id: 'precise/ceph-9', 427 id: 'precise/ceph-9',
428 code_source: { location: 'lp:~foo' }, 428 code_source: { location: 'lp:~foo' },
429 options: { 429 options: {
430 'client-port': { 430 'client-port': {
431 'default': 9160, 431 'default': 9160,
432 'description': 'Port for client communcation', 432 'description': 'Port for client communcation',
433 'type': 'int' 433 'type': 'int'
434 } 434 }
435 } 435 }
436 }), 436 }),
437 container: utils.makeContainer() 437 container: utils.makeContainer()
438 }); 438 });
439 view.render(); 439 view.render();
440 440
441 Y.one('#bws-configuration dd div').get('text').should.eql( 441 Y.one('#bws-configuration dd div').get('text').should.eql(
442 'Default: 9160'); 442 'Default: 9160');
443 Y.one('#bws-configuration dd p').get('text').should.eql( 443 Y.one('#bws-configuration dd p').get('text').should.eql(
444 'Port for client communcation'); 444 'Port for client communcation');
445 }); 445 });
446 446
447 it('_buildQAData properly summerizes the scores', function() { 447 it('_buildQAData properly summerizes the scores', function() {
448 view = new CharmView({ 448 view = new CharmView({
449 charm: new models.BrowserCharm({ 449 charm: new models.Charm({
450 files: [ 450 files: [
451 'readme.md' 451 'readme.md'
452 ], 452 ],
453 id: 'precise/ceph-9', 453 id: 'precise/ceph-9',
454 is_approved: true, 454 is_approved: true,
455 code_source: { location: 'lp:~foo' } 455 code_source: { location: 'lp:~foo' }
456 }) 456 })
457 }); 457 });
458 var data = utils.loadFixture('data/qa.json', true); 458 var data = utils.loadFixture('data/qa.json', true);
459 var processed = view._buildQAData(data); 459 var processed = view._buildQAData(data);
460 460
461 // We store a number of summary bits to help the template render the 461 // We store a number of summary bits to help the template render the
462 // scores correctly. 462 // scores correctly.
463 processed.totalAvailable.should.eql(38); 463 processed.totalAvailable.should.eql(38);
464 processed.totalScore.should.eql(13); 464 processed.totalScore.should.eql(13);
465 processed.questions[0].score.should.eql(3); 465 processed.questions[0].score.should.eql(3);
466 assert.ok(processed.charm.is_approved); 466 assert.ok(processed.charm.is_approved);
467 467
468 }); 468 });
469 469
470 it('does not blow up when the scores from the api is null', function() { 470 it('does not blow up when the scores from the api is null', function() {
471 view = new CharmView({ 471 view = new CharmView({
472 charm: new models.BrowserCharm({ 472 charm: new models.Charm({
473 files: [ 473 files: [
474 'readme.md' 474 'readme.md'
475 ], 475 ],
476 id: 'precise/ceph-9', 476 id: 'precise/ceph-9',
477 code_source: { location: 'lp:~foo' } 477 code_source: { location: 'lp:~foo' }
478 }) 478 })
479 }); 479 });
480 var data = utils.loadFixture('data/qa.json', true); 480 var data = utils.loadFixture('data/qa.json', true);
481 // munge the data so that scores is null. 481 // munge the data so that scores is null.
482 data.scores = null; 482 data.scores = null;
(...skipping 18 matching lines...) Expand all
501 response: { 501 response: {
502 results: [{ 502 results: [{
503 responseText: fakedata 503 responseText: fakedata
504 }] 504 }]
505 } 505 }
506 }); 506 });
507 } 507 }
508 }); 508 });
509 509
510 view = new CharmView({ 510 view = new CharmView({
511 charm: new models.BrowserCharm({ 511 charm: new models.Charm({
512 files: [], 512 files: [],
513 id: 'precise/ceph-9', 513 id: 'precise/ceph-9',
514 code_source: { location: 'lp:~foo' } 514 code_source: { location: 'lp:~foo' }
515 }), 515 }),
516 renderTo: testContainer, 516 renderTo: testContainer,
517 store: fakeStore 517 store: fakeStore
518 }); 518 });
519 519
520 view.render(); 520 view.render();
521 // Force the loading of the qa div. 521 // Force the loading of the qa div.
(...skipping 14 matching lines...) Expand all
536 assert.ok(foundNode); 536 assert.ok(foundNode);
537 // Little cleanup. 537 // Little cleanup.
538 testContainer.remove(true); 538 testContainer.remove(true);
539 }); 539 });
540 540
541 it('should catch when the open log is clicked', function(done) { 541 it('should catch when the open log is clicked', function(done) {
542 var data = utils.loadFixture('data/browsercharm.json', true); 542 var data = utils.loadFixture('data/browsercharm.json', true);
543 // We don't want any files so we don't have to mock/load them. 543 // We don't want any files so we don't have to mock/load them.
544 data.charm.files = []; 544 data.charm.files = [];
545 view = new CharmView({ 545 view = new CharmView({
546 charm: new models.BrowserCharm(data.charm), 546 charm: new models.Charm(data.charm),
547 container: utils.makeContainer() 547 container: utils.makeContainer()
548 }); 548 });
549 549
550 // Hook up to the callback for the click event. 550 // Hook up to the callback for the click event.
551 view._toggleLog = function(ev) { 551 view._toggleLog = function(ev) {
552 ev.halt(); 552 ev.halt();
553 done(); 553 done();
554 }; 554 };
555 555
556 view.render(); 556 view.render();
557 node.one('.changelog .expand').simulate('click'); 557 node.one('.changelog .expand').simulate('click');
558 }); 558 });
559 559
560 it('changelog is reformatted and displayed', function() { 560 it('changelog is reformatted and displayed', function() {
561 var data = utils.loadFixture('data/browsercharm.json', true); 561 var data = utils.loadFixture('data/browsercharm.json', true);
562 // We don't want any files so we don't have to mock/load them. 562 // We don't want any files so we don't have to mock/load them.
563 data.charm.files = []; 563 data.charm.files = [];
564 view = new CharmView({ 564 view = new CharmView({
565 charm: new models.BrowserCharm(data.charm), 565 charm: new models.Charm(data.charm),
566 container: utils.makeContainer() 566 container: utils.makeContainer()
567 }); 567 });
568 568
569 view.render(); 569 view.render();
570 // Basics that we have the right number of nodes. 570 // Basics that we have the right number of nodes.
571 node.all('.remaining li').size().should.eql(9); 571 node.all('.remaining li').size().should.eql(9);
572 node.all('.first p').size().should.eql(1); 572 node.all('.first p').size().should.eql(1);
573 573
574 // The reminaing starts out hidden. 574 // The reminaing starts out hidden.
575 assert(node.one('.changelog .remaining').hasClass('hidden')); 575 assert(node.one('.changelog .remaining').hasClass('hidden'));
576 }); 576 });
577 577
578 it('_getInterfaceIntroFlag sets the flag for no requires, no provides', 578 it('_getInterfaceIntroFlag sets the flag for no requires, no provides',
579 function() { 579 function() {
580 var charm = new models.BrowserCharm({ 580 var charm = new models.Charm({
581 files: [], 581 files: [],
582 id: 'precise/ceph-9', 582 id: 'precise/ceph-9',
583 relations: { 583 relations: {
584 'provides': { 584 'provides': {
585 }, 585 },
586 'requires': { 586 'requires': {
587 } 587 }
588 } 588 }
589 }); 589 });
590 view = new CharmView({ 590 view = new CharmView({
591 charm: charm 591 charm: charm
592 }); 592 });
593 var interfaceIntro = view._getInterfaceIntroFlag( 593 var interfaceIntro = view._getInterfaceIntroFlag(
594 charm.get('requires'), charm.get('provides')); 594 charm.get('requires'), charm.get('provides'));
595 assert(Y.Object.hasKey(interfaceIntro, 'noRequiresNoProvides')); 595 assert(Y.Object.hasKey(interfaceIntro, 'noRequiresNoProvides'));
596 }); 596 });
597 597
598 it('_getInterfaceIntroFlag sets the flag for no requires, 1 provides', 598 it('_getInterfaceIntroFlag sets the flag for no requires, 1 provides',
599 function() { 599 function() {
600 var charm = new models.BrowserCharm({ 600 var charm = new models.Charm({
601 files: [], 601 files: [],
602 id: 'precise/ceph-9', 602 id: 'precise/ceph-9',
603 relations: { 603 relations: {
604 'provides': { 604 'provides': {
605 'foo': {} 605 'foo': {}
606 }, 606 },
607 'requires': { 607 'requires': {
608 } 608 }
609 } 609 }
610 }); 610 });
611 view = new CharmView({ 611 view = new CharmView({
612 charm: charm 612 charm: charm
613 }); 613 });
614 var interfaceIntro = view._getInterfaceIntroFlag( 614 var interfaceIntro = view._getInterfaceIntroFlag(
615 charm.get('requires'), charm.get('provides')); 615 charm.get('requires'), charm.get('provides'));
616 assert(Y.Object.hasKey(interfaceIntro, 'noRequiresOneProvides')); 616 assert(Y.Object.hasKey(interfaceIntro, 'noRequiresOneProvides'));
617 }); 617 });
618 618
619 it('_getInterfaceIntroFlag sets the flag for no requires, many provides', 619 it('_getInterfaceIntroFlag sets the flag for no requires, many provides',
620 function() { 620 function() {
621 var charm = new models.BrowserCharm({ 621 var charm = new models.Charm({
622 files: [], 622 files: [],
623 id: 'precise/ceph-9', 623 id: 'precise/ceph-9',
624 relations: { 624 relations: {
625 'provides': { 625 'provides': {
626 'foo': {}, 626 'foo': {},
627 'two': {} 627 'two': {}
628 }, 628 },
629 'requires': { 629 'requires': {
630 } 630 }
631 } 631 }
632 }); 632 });
633 view = new CharmView({ 633 view = new CharmView({
634 charm: charm 634 charm: charm
635 }); 635 });
636 var interfaceIntro = view._getInterfaceIntroFlag( 636 var interfaceIntro = view._getInterfaceIntroFlag(
637 charm.get('requires'), charm.get('provides')); 637 charm.get('requires'), charm.get('provides'));
638 assert(Y.Object.hasKey(interfaceIntro, 'noRequiresManyProvides')); 638 assert(Y.Object.hasKey(interfaceIntro, 'noRequiresManyProvides'));
639 }); 639 });
640 640
641 it('_getInterfaceIntroFlag sets the flag for 1 requires, no provides', 641 it('_getInterfaceIntroFlag sets the flag for 1 requires, no provides',
642 function() { 642 function() {
643 var charm = new models.BrowserCharm({ 643 var charm = new models.Charm({
644 files: [], 644 files: [],
645 id: 'precise/ceph-9', 645 id: 'precise/ceph-9',
646 relations: { 646 relations: {
647 'provides': { 647 'provides': {
648 }, 648 },
649 'requires': { 649 'requires': {
650 'foo': {} 650 'foo': {}
651 } 651 }
652 } 652 }
653 }); 653 });
654 view = new CharmView({ 654 view = new CharmView({
655 charm: charm 655 charm: charm
656 }); 656 });
657 var interfaceIntro = view._getInterfaceIntroFlag( 657 var interfaceIntro = view._getInterfaceIntroFlag(
658 charm.get('requires'), charm.get('provides')); 658 charm.get('requires'), charm.get('provides'));
659 assert(Y.Object.hasKey(interfaceIntro, 'oneRequiresNoProvides')); 659 assert(Y.Object.hasKey(interfaceIntro, 'oneRequiresNoProvides'));
660 }); 660 });
661 661
662 it('_getInterfaceIntroFlag sets the flag for 1 requires, 1 provides', 662 it('_getInterfaceIntroFlag sets the flag for 1 requires, 1 provides',
663 function() { 663 function() {
664 var charm = new models.BrowserCharm({ 664 var charm = new models.Charm({
665 files: [], 665 files: [],
666 id: 'precise/ceph-9', 666 id: 'precise/ceph-9',
667 relations: { 667 relations: {
668 'provides': { 668 'provides': {
669 'foo': {} 669 'foo': {}
670 }, 670 },
671 'requires': { 671 'requires': {
672 'foo': {} 672 'foo': {}
673 } 673 }
674 } 674 }
675 }); 675 });
676 view = new CharmView({ 676 view = new CharmView({
677 charm: charm 677 charm: charm
678 }); 678 });
679 var interfaceIntro = view._getInterfaceIntroFlag( 679 var interfaceIntro = view._getInterfaceIntroFlag(
680 charm.get('requires'), charm.get('provides')); 680 charm.get('requires'), charm.get('provides'));
681 assert(Y.Object.hasKey(interfaceIntro, 'oneRequiresOneProvides')); 681 assert(Y.Object.hasKey(interfaceIntro, 'oneRequiresOneProvides'));
682 }); 682 });
683 683
684 it('_getInterfaceIntroFlag sets the flag for 1 requires, many provides', 684 it('_getInterfaceIntroFlag sets the flag for 1 requires, many provides',
685 function() { 685 function() {
686 var charm = new models.BrowserCharm({ 686 var charm = new models.Charm({
687 files: [], 687 files: [],
688 id: 'precise/ceph-9', 688 id: 'precise/ceph-9',
689 relations: { 689 relations: {
690 'provides': { 690 'provides': {
691 'foo': {}, 691 'foo': {},
692 'two': {} 692 'two': {}
693 }, 693 },
694 'requires': { 694 'requires': {
695 'foo': {} 695 'foo': {}
696 } 696 }
697 } 697 }
698 }); 698 });
699 view = new CharmView({ 699 view = new CharmView({
700 charm: charm 700 charm: charm
701 }); 701 });
702 var interfaceIntro = view._getInterfaceIntroFlag( 702 var interfaceIntro = view._getInterfaceIntroFlag(
703 charm.get('requires'), charm.get('provides')); 703 charm.get('requires'), charm.get('provides'));
704 assert(Y.Object.hasKey(interfaceIntro, 'oneRequiresManyProvides')); 704 assert(Y.Object.hasKey(interfaceIntro, 'oneRequiresManyProvides'));
705 }); 705 });
706 706
707 it('_getInterfaceIntroFlag sets the flag for many requires, no provides', 707 it('_getInterfaceIntroFlag sets the flag for many requires, no provides',
708 function() { 708 function() {
709 var charm = new models.BrowserCharm({ 709 var charm = new models.Charm({
710 files: [], 710 files: [],
711 id: 'precise/ceph-9', 711 id: 'precise/ceph-9',
712 relations: { 712 relations: {
713 'provides': { 713 'provides': {
714 }, 714 },
715 'requires': { 715 'requires': {
716 'foo': {}, 716 'foo': {},
717 'two': {} 717 'two': {}
718 } 718 }
719 } 719 }
720 }); 720 });
721 view = new CharmView({ 721 view = new CharmView({
722 charm: charm 722 charm: charm
723 }); 723 });
724 var interfaceIntro = view._getInterfaceIntroFlag( 724 var interfaceIntro = view._getInterfaceIntroFlag(
725 charm.get('requires'), charm.get('provides')); 725 charm.get('requires'), charm.get('provides'));
726 assert(Y.Object.hasKey(interfaceIntro, 'manyRequiresNoProvides')); 726 assert(Y.Object.hasKey(interfaceIntro, 'manyRequiresNoProvides'));
727 }); 727 });
728 728
729 it('_getInterfaceIntroFlag sets the flag for many requires, 1 provides', 729 it('_getInterfaceIntroFlag sets the flag for many requires, 1 provides',
730 function() { 730 function() {
731 var charm = new models.BrowserCharm({ 731 var charm = new models.Charm({
732 files: [], 732 files: [],
733 id: 'precise/ceph-9', 733 id: 'precise/ceph-9',
734 relations: { 734 relations: {
735 'provides': { 735 'provides': {
736 'foo': {} 736 'foo': {}
737 }, 737 },
738 'requires': { 738 'requires': {
739 'foo': {}, 739 'foo': {},
740 'two': {} 740 'two': {}
741 } 741 }
742 } 742 }
743 }); 743 });
744 view = new CharmView({ 744 view = new CharmView({
745 charm: charm 745 charm: charm
746 }); 746 });
747 var interfaceIntro = view._getInterfaceIntroFlag( 747 var interfaceIntro = view._getInterfaceIntroFlag(
748 charm.get('requires'), charm.get('provides')); 748 charm.get('requires'), charm.get('provides'));
749 assert(Y.Object.hasKey(interfaceIntro, 'manyRequiresOneProvides')); 749 assert(Y.Object.hasKey(interfaceIntro, 'manyRequiresOneProvides'));
750 }); 750 });
751 751
752 it('_getInterfaceIntroFlag sets the flag for many requires, many provides', 752 it('_getInterfaceIntroFlag sets the flag for many requires, many provides',
753 function() { 753 function() {
754 var charm = new models.BrowserCharm({ 754 var charm = new models.Charm({
755 files: [], 755 files: [],
756 id: 'precise/ceph-9', 756 id: 'precise/ceph-9',
757 relations: { 757 relations: {
758 'provides': { 758 'provides': {
759 'foo': {}, 759 'foo': {},
760 'two': {} 760 'two': {}
761 }, 761 },
762 'requires': { 762 'requires': {
763 'foo': {}, 763 'foo': {},
764 'two': {} 764 'two': {}
(...skipping 13 matching lines...) Expand all
778 // We don't want any files so we don't have to mock/load them. 778 // We don't want any files so we don't have to mock/load them.
779 data.charm.files = []; 779 data.charm.files = [];
780 // Add a failing test to the charm data. 780 // Add a failing test to the charm data.
781 data.charm.tested_providers = { 781 data.charm.tested_providers = {
782 'ec2': 'FAILURE', 782 'ec2': 'FAILURE',
783 'local': 'SUCCESS', 783 'local': 'SUCCESS',
784 'openstack': 'FAILURE' 784 'openstack': 'FAILURE'
785 }; 785 };
786 786
787 view = new CharmView({ 787 view = new CharmView({
788 charm: new models.BrowserCharm(data.charm), 788 charm: new models.Charm(data.charm),
789 container: utils.makeContainer() 789 container: utils.makeContainer()
790 }); 790 });
791 791
792 view.render(); 792 view.render();
793 // Basics that we have the right number of nodes. 793 // Basics that we have the right number of nodes.
794 node.all('.providers .successes li').size().should.eql(1); 794 node.all('.providers .successes li').size().should.eql(1);
795 node.all('.providers .failures li').size().should.eql(2); 795 node.all('.providers .failures li').size().should.eql(2);
796 }); 796 });
797 797
798 it('shows and hides an indicator', function(done) { 798 it('shows and hides an indicator', function(done) {
799 var hit = 0; 799 var hit = 0;
800 800
801 var data = utils.loadFixture('data/browsercharm.json', true); 801 var data = utils.loadFixture('data/browsercharm.json', true);
802 // We don't want any files so we don't have to mock/load them. 802 // We don't want any files so we don't have to mock/load them.
803 data.charm.files = []; 803 data.charm.files = [];
804 view = new CharmView({ 804 view = new CharmView({
805 charm: new models.BrowserCharm(data.charm), 805 charm: new models.Charm(data.charm),
806 container: utils.makeContainer() 806 container: utils.makeContainer()
807 }); 807 });
808 808
809 view.showIndicator = function() { 809 view.showIndicator = function() {
810 hit += 1; 810 hit += 1;
811 }; 811 };
812 view.hideIndicator = function() { 812 view.hideIndicator = function() {
813 hit += 1; 813 hit += 1;
814 hit.should.equal(2); 814 hit.should.equal(2);
815 done(); 815 done();
816 }; 816 };
817 view.render(); 817 view.render();
818 }); 818 });
819 819
820 it('selects the proper tab when given one', function() { 820 it('selects the proper tab when given one', function() {
821 var data = utils.loadFixture('data/browsercharm.json', true); 821 var data = utils.loadFixture('data/browsercharm.json', true);
822 // We don't want any files so we don't have to mock/load them. 822 // We don't want any files so we don't have to mock/load them.
823 data.charm.files = []; 823 data.charm.files = [];
824 824
825 view = new CharmView({ 825 view = new CharmView({
826 activeTab: '#bws-configuration', 826 activeTab: '#bws-configuration',
827 charm: new models.BrowserCharm(data.charm), 827 charm: new models.Charm(data.charm),
828 container: utils.makeContainer() 828 container: utils.makeContainer()
829 }); 829 });
830 830
831 view.render(); 831 view.render();
832 832
833 // We've selected the activeTab specified. 833 // We've selected the activeTab specified.
834 var selected = view.get('container').one('.yui3-tab-selected a'); 834 var selected = view.get('container').one('.yui3-tab-selected a');
835 assert.equal(selected.getAttribute('href'), '#bws-configuration'); 835 assert.equal(selected.getAttribute('href'), '#bws-configuration');
836 }); 836 });
837 837
(...skipping 11 matching lines...) Expand all
849 response: { 849 response: {
850 results: [{ 850 results: [{
851 responseText: utils.loadFixture('data/related.json') 851 responseText: utils.loadFixture('data/related.json')
852 }] 852 }]
853 } 853 }
854 }); 854 });
855 } 855 }
856 }); 856 });
857 857
858 view = new CharmView({ 858 view = new CharmView({
859 charm: new models.BrowserCharm(data), 859 charm: new models.Charm(data),
860 isFullscreen: true, 860 isFullscreen: true,
861 renderTo: testContainer, 861 renderTo: testContainer,
862 store: fakeStore 862 store: fakeStore
863 }); 863 });
864 view.render(); 864 view.render();
865 865
866 // We've selected the activeTab specified. 866 // We've selected the activeTab specified.
867 var tokens = view.get('container').all('.charm-token'); 867 var tokens = view.get('container').all('.charm-token');
868 assert.equal(tokens.size(), 5); 868 assert.equal(tokens.size(), 5);
869 869
(...skipping 26 matching lines...) Expand all
896 results: [{ 896 results: [{
897 responseText: utils.loadFixture('data/related.json') 897 responseText: utils.loadFixture('data/related.json')
898 }] 898 }]
899 } 899 }
900 }); 900 });
901 } 901 }
902 }); 902 });
903 903
904 view = new CharmView({ 904 view = new CharmView({
905 activeTab: '#bws-related-charms', 905 activeTab: '#bws-related-charms',
906 charm: new models.BrowserCharm(data), 906 charm: new models.Charm(data),
907 isFullscreen: true, 907 isFullscreen: true,
908 renderTo: testContainer, 908 renderTo: testContainer,
909 store: fakeStore 909 store: fakeStore
910 }); 910 });
911 view.render(); 911 view.render();
912 912
913 assert.equal( 913 assert.equal(
914 testContainer.all('#bws-related-charms .charm-token').size(), 914 testContainer.all('#bws-related-charms .charm-token').size(),
915 9); 915 9);
916 assert.isTrue(view.loadedRelatedInterfaceCharms); 916 assert.isTrue(view.loadedRelatedInterfaceCharms);
(...skipping 14 matching lines...) Expand all
931 results: [{ 931 results: [{
932 responseText: utils.loadFixture('data/related.json') 932 responseText: utils.loadFixture('data/related.json')
933 }] 933 }]
934 } 934 }
935 }); 935 });
936 } 936 }
937 }); 937 });
938 938
939 view = new CharmView({ 939 view = new CharmView({
940 activeTab: '#bws-related-charms', 940 activeTab: '#bws-related-charms',
941 charm: new models.BrowserCharm(data), 941 charm: new models.Charm(data),
942 isFullscreen: true, 942 isFullscreen: true,
943 renderTo: testContainer, 943 renderTo: testContainer,
944 store: fakeStore 944 store: fakeStore
945 }); 945 });
946 946
947 var origLoadRelatedCharms = view._loadRelatedCharms; 947 var origLoadRelatedCharms = view._loadRelatedCharms;
948 var state = { 948 var state = {
949 loadCount: 0, 949 loadCount: 0,
950 hitTabRender: false, 950 hitTabRender: false,
951 hitRelatedRender: false 951 hitRelatedRender: false
(...skipping 30 matching lines...) Expand all
982 results: [{ 982 results: [{
983 responseText: utils.loadFixture('data/related.json') 983 responseText: utils.loadFixture('data/related.json')
984 }] 984 }]
985 } 985 }
986 }); 986 });
987 } 987 }
988 }); 988 });
989 989
990 view = new CharmView({ 990 view = new CharmView({
991 activeTab: '#bws-does-not-exist', 991 activeTab: '#bws-does-not-exist',
992 charm: new models.BrowserCharm(data), 992 charm: new models.Charm(data),
993 isFullscreen: true, 993 isFullscreen: true,
994 renderTo: testContainer, 994 renderTo: testContainer,
995 store: fakeStore 995 store: fakeStore
996 }); 996 });
997 view.render(); 997 view.render();
998 998
999 assert.equal( 999 assert.equal(
1000 testContainer.one('.yui3-tab-selected a').getAttribute('href'), 1000 testContainer.one('.yui3-tab-selected a').getAttribute('href'),
1001 '#bws-summary'); 1001 '#bws-summary');
1002 }); 1002 });
1003 1003
1004 }); 1004 });
1005 1005
1006 })(); 1006 })();
OLDNEW
« no previous file with comments | « app/widgets/charm-token.js ('k') | test/test_browser_search_view.js » ('j') | no next file with comments »

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