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

Side by Side Diff: test/test_service_view.js

Issue 6733060: Filter buttons should match design
Patch Set: Filter buttons should match design Created 12 years, 5 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 | « lib/views/stylesheet.less ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 'use strict'; 1 'use strict';
2 2
3 (function() { 3 (function() {
4 describe('juju service view', function() { 4 describe('juju service view', function() {
5 var models, Y, container, service, db, conn, env, charm, ENTER, ESC, 5 var models, Y, container, service, db, conn, env, charm, ENTER, ESC,
6 makeServiceView, makeServiceRelationsView, views, unit; 6 makeServiceView, makeServiceRelationsView, views, unit;
7 7
8 before(function(done) { 8 before(function(done) {
9 Y = YUI(GlobalConfig).use( 9 Y = YUI(GlobalConfig).use(
10 'juju-views', 'juju-models', 'base', 'node', 'json-parse', 10 'juju-views', 'juju-models', 'base', 'node', 'json-parse',
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 365
366 test('.exposeService', '.unexposeService', 366 test('.exposeService', '.unexposeService',
367 Y.bind(view._exposeServiceCallback, view)); 367 Y.bind(view._exposeServiceCallback, view));
368 test('.unexposeService', '.exposeService', 368 test('.unexposeService', '.exposeService',
369 Y.bind(view._unexposeServiceCallback, view)); 369 Y.bind(view._unexposeServiceCallback, view));
370 }); 370 });
371 371
372 it('should show proper tabs initially', function() { 372 it('should show proper tabs initially', function() {
373 var view = makeServiceView(), 373 var view = makeServiceView(),
374 active_navtabs = []; 374 active_navtabs = [];
375 container.all('.state-btn').each( 375 container.all('.state-title').each(
376 function(n) { 376 function(n) {
377 active_navtabs.push([n.one('.state-title').get('text').trim(), 377 active_navtabs.push([n.get('text').trim(),
378 n.hasClass('btn-primary')]); 378 n.hasClass('active')]);
379 }); 379 });
380 active_navtabs.should.eql( 380 active_navtabs.should.eql(
381 [['All', true], 381 [['All', true],
382 ['Running', false], 382 ['Running', false],
383 ['Pending', false], 383 ['Pending', false],
384 ['Error', false]]); 384 ['Error', false]]);
385 }); 385 });
386 386
387 it('should show zero running units when filtered', function() { 387 it('should show zero running units when filtered', function() {
388 // All units are pending. 388 // All units are pending.
389 var view = makeServiceView({state: 'running'}), 389 var view = makeServiceView({state: 'running'}),
390 active_navtabs = []; 390 active_navtabs = [];
391 container.all('.state-btn').each( 391 container.all('.state-title').each(
392 function(n) { 392 function(n) {
393 active_navtabs.push([n.one('.state-title').get('text').trim(), 393 active_navtabs.push([n.get('text').trim(),
394 n.hasClass('btn-primary')]); 394 n.hasClass('active')]);
395 }); 395 });
396 active_navtabs.should.eql( 396 active_navtabs.should.eql(
397 [['All', false], 397 [['All', false],
398 ['Running', true], 398 ['Running', true],
399 ['Pending', false], 399 ['Pending', false],
400 ['Error', false]]); 400 ['Error', false]]);
401 container.all('div.thumbnail').get('id').length.should.equal(0); 401 container.all('div.thumbnail').get('id').length.should.equal(0);
402 }); 402 });
403 403
404 it('should show some running units when filtered', function() { 404 it('should show some running units when filtered', function() {
405 db.units.getById('mysql/0').agent_state = 'started'; 405 db.units.getById('mysql/0').agent_state = 'started';
406 // 1 is pending. 406 // 1 is pending.
407 db.units.getById('mysql/2').agent_state = 'started'; 407 db.units.getById('mysql/2').agent_state = 'started';
408 var view = makeServiceView({state: 'running'}); 408 var view = makeServiceView({state: 'running'});
409 var rendered_names = container.one( 409 var rendered_names = container.one(
410 'ul.thumbnails').all('div.unit').get('id'); 410 'ul.thumbnails').all('div.unit').get('id');
411 rendered_names.should.eql(['mysql/0', 'mysql/2']); 411 rendered_names.should.eql(['mysql/0', 'mysql/2']);
412 }); 412 });
413 413
414 it('should show zero pending units when filtered', function() { 414 it('should show zero pending units when filtered', function() {
415 db.units.getById('mysql/0').agent_state = 'install-error'; 415 db.units.getById('mysql/0').agent_state = 'install-error';
416 db.units.getById('mysql/1').agent_state = 'error'; 416 db.units.getById('mysql/1').agent_state = 'error';
417 db.units.getById('mysql/2').agent_state = 'started'; 417 db.units.getById('mysql/2').agent_state = 'started';
418 var view = makeServiceView({state: 'pending'}), 418 var view = makeServiceView({state: 'pending'}),
419 active_navtabs = []; 419 active_navtabs = [];
420 container.all('.state-btn').each( 420 container.all('.state-title').each(
421 function(n) { 421 function(n) {
422 active_navtabs.push([n.one('.state-title').get('text').trim(), 422 active_navtabs.push([n.get('text').trim(),
423 n.hasClass('btn-primary')]); 423 n.hasClass('active')]);
424 }); 424 });
425 active_navtabs.should.eql( 425 active_navtabs.should.eql(
426 [['All', false], 426 [['All', false],
427 ['Running', false], 427 ['Running', false],
428 ['Pending', true], 428 ['Pending', true],
429 ['Error', false]]); 429 ['Error', false]]);
430 container.all('div.thumbnail').get('id').length.should.equal(0); 430 container.all('div.thumbnail').get('id').length.should.equal(0);
431 }); 431 });
432 432
433 it('should show some pending units when filtered', function() { 433 it('should show some pending units when filtered', function() {
434 // 0 is pending already. 434 // 0 is pending already.
435 db.units.getById('mysql/1').agent_state = 'started'; 435 db.units.getById('mysql/1').agent_state = 'started';
436 // We include installed with pending. 436 // We include installed with pending.
437 db.units.getById('mysql/2').agent_state = 'installed'; 437 db.units.getById('mysql/2').agent_state = 'installed';
438 var view = makeServiceView({state: 'pending'}); 438 var view = makeServiceView({state: 'pending'});
439 var rendered_names = container.one( 439 var rendered_names = container.one(
440 'ul.thumbnails').all('div.unit').get('id'); 440 'ul.thumbnails').all('div.unit').get('id');
441 rendered_names.should.eql(['mysql/0', 'mysql/2']); 441 rendered_names.should.eql(['mysql/0', 'mysql/2']);
442 }); 442 });
443 443
444 it('should show zero error units when filtered', function() { 444 it('should show zero error units when filtered', function() {
445 var view = makeServiceView({state: 'error'}), 445 var view = makeServiceView({state: 'error'}),
446 active_navtabs = []; 446 active_navtabs = [];
447 container.all('.state-btn').each( 447 container.all('.state-title').each(
448 function(n) { 448 function(n) {
449 active_navtabs.push([n.one('.state-title').get('text').trim(), 449 active_navtabs.push([n.get('text').trim(),
450 n.hasClass('btn-primary')]); 450 n.hasClass('active')]);
451 }); 451 });
452 active_navtabs.should.eql( 452 active_navtabs.should.eql(
453 [['All', false], 453 [['All', false],
454 ['Running', false], 454 ['Running', false],
455 ['Pending', false], 455 ['Pending', false],
456 ['Error', true]]); 456 ['Error', true]]);
457 container.all('div.thumbnail').get('id').length.should.equal(0); 457 container.all('div.thumbnail').get('id').length.should.equal(0);
458 }); 458 });
459 459
460 it('should show some error units when filtered', function() { 460 it('should show some error units when filtered', function() {
(...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after
662 agent_state: 'error' 662 agent_state: 'error'
663 }], filtered = views.service.prototype.filterUnits('error', units); 663 }], filtered = views.service.prototype.filterUnits('error', units);
664 664
665 assert.equal(2, filtered.length); 665 assert.equal(2, filtered.length);
666 assert.equal('error1', filtered[0].testKey); 666 assert.equal('error1', filtered[0].testKey);
667 assert.equal('error2', filtered[1].testKey); 667 assert.equal('error2', filtered[1].testKey);
668 }); 668 });
669 669
670 }); 670 });
671 }) (); 671 }) ();
OLDNEW
« no previous file with comments | « lib/views/stylesheet.less ('k') | no next file » | no next file with comments »

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