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

Side by Side Diff: test/test_ghost_inspector.js

Issue 36500044: Validates the service names on user entry
Patch Set: Validates the service names on user entry Created 11 years, 3 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
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) 2013 Canonical Ltd. 4 Copyright (C) 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 }); 51 });
52 52
53 afterEach(function(done) { 53 afterEach(function(done) {
54 cleanIconHelper(); 54 cleanIconHelper();
55 if (view) { 55 if (view) {
56 if (inspector) { 56 if (inspector) {
57 view.setInspector(inspector, true); 57 view.setInspector(inspector, true);
58 } 58 }
59 view.destroy(); 59 view.destroy();
60 } 60 }
61 db.destroy();
61 env.after('destroy', function() { done(); }); 62 env.after('destroy', function() { done(); });
62 env.destroy(); 63 env.destroy();
63 container.remove(true); 64 container.remove(true);
64 window.flags = {}; 65 window.flags = {};
65 }); 66 });
66 67
67 var setUpInspector = function(data) { 68 var setUpInspector = function(data) {
68 if (!data) { 69 if (!data) {
69 data = charmData; 70 data = charmData;
70 } 71 }
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 db.services.add({id: 'mediawiki', charm: 'cs:precise/mediawiki'}); 132 db.services.add({id: 'mediawiki', charm: 'cs:precise/mediawiki'});
132 inspector = setUpInspector(); 133 inspector = setUpInspector();
133 var serviceNameInput = Y.one('input[name=service-name]'); 134 var serviceNameInput = Y.one('input[name=service-name]');
134 // This is usually fired by an event. The event simulation is broken as 135 // This is usually fired by an event. The event simulation is broken as
135 // of this writing, and we can do more of a unit test this way. 136 // of this writing, and we can do more of a unit test this way.
136 inspector.updateGhostName( 137 inspector.updateGhostName(
137 {newVal: 'mediawiki42', currentTarget: serviceNameInput}); 138 {newVal: 'mediawiki42', currentTarget: serviceNameInput});
138 assert.isFalse(serviceNameInput.hasClass('invalid')); 139 assert.isFalse(serviceNameInput.hasClass('invalid'));
139 assert.isTrue(serviceNameInput.hasClass('valid')); 140 assert.isTrue(serviceNameInput.hasClass('valid'));
140 }); 141 });
142
143 it('won\'t let you deploy a service with an invalid name', function() {
144 db.services.add({id: 'mediawiki', charm: 'cs:precise/mediawiki'});
145 inspector = setUpInspector();
146 var newName = 'foo-2',
147 serviceNameInput = Y.one('input[name=service-name]');
rharding 2013/12/03 17:06:27 do we have to do a Y.one? Isn't there a container
jeff.pihach 2013/12/03 17:16:32 copied this from the previous tests.
148 // This is usually fired by an event. The event simulation is broken as
149 // of this writing, and we can do more of a unit test this way.
rharding 2013/12/03 17:06:27 :(
150 serviceNameInput.set('value', newName);
151 inspector.updateGhostName(
152 {newVal: newName, currentTarget: serviceNameInput});
153 assert.isTrue(serviceNameInput.hasClass('invalid'));
154 assert.isFalse(serviceNameInput.hasClass('valid'));
155 inspector.options.env.deploy = function() {
156 assert.fail('The method should exit before this function is called.');
157 };
158 assert.isFalse(inspector.deployCharm());
159 });
141 }); 160 });
142 161
143 it('updates the service name in the topology when changed in the inspector', 162 it('updates the service name in the topology when changed in the inspector',
144 function(done) { 163 function(done) {
145 // XXX (Jeff) YUI's simulate can't properly simulate focus or blur in 164 // XXX (Jeff) YUI's simulate can't properly simulate focus or blur in
146 // IE10 as of 3.9.1, 3.11 https://github.com/yui/yui3/issues/489 165 // IE10 as of 3.9.1, 3.11 https://github.com/yui/yui3/issues/489
147 if (Y.UA.ie === 10) { 166 if (Y.UA.ie === 10) {
148 done(); 167 done();
149 } 168 }
150 inspector = setUpInspector(); 169 inspector = setUpInspector();
(...skipping 388 matching lines...) Expand 10 before | Expand all | Expand 10 after
539 inspector = setUpInspector(); 558 inspector = setUpInspector();
540 var events = inspector.viewletManager.events; 559 var events = inspector.viewletManager.events;
541 assert.equal( 560 assert.equal(
542 typeof events['.destroy-service-trigger span'].click, 'function'); 561 typeof events['.destroy-service-trigger span'].click, 'function');
543 assert.equal(typeof events['.initiate-destroy'].click, 'function'); 562 assert.equal(typeof events['.initiate-destroy'].click, 'function');
544 assert.equal(typeof events['.cancel-destroy'].click, 'function'); 563 assert.equal(typeof events['.cancel-destroy'].click, 'function');
545 }); 564 });
546 }); 565 });
547 566
548 }); 567 });
OLDNEW

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