Left: | ||
Right: |
LEFT | RIGHT |
---|---|
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 |
11 ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, | 11 ANY WARRANTY; without even the implied warranties of MERCHANTABILITY, |
12 SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero | 12 SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero |
13 General Public License for more details. | 13 General Public License for more details. |
14 | 14 |
15 You should have received a copy of the GNU Affero General Public License along | 15 You should have received a copy of the GNU Affero General Public License along |
16 with this program. If not, see <http://www.gnu.org/licenses/>. | 16 with this program. If not, see <http://www.gnu.org/licenses/>. |
17 */ | 17 */ |
18 | 18 |
19 'use strict'; | 19 'use strict'; |
20 | 20 |
21 describe('service module annotations', function() { | 21 describe('service module annotations', function() { |
22 var db, juju, models, utils, viewContainer, views, Y, serviceModule; | 22 var db, juju, models, utils, viewContainer, views, Y, serviceModule; |
23 var called, location; | 23 var called, location; |
24 | |
24 before(function(done) { | 25 before(function(done) { |
25 Y = YUI(GlobalConfig).use(['node', | 26 Y = YUI(GlobalConfig).use([ |
27 'juju-gui', | |
28 'juju-models', | |
26 'juju-tests-utils', | 29 'juju-tests-utils', |
27 'juju-models', | |
28 'juju-views', | 30 'juju-views', |
29 'juju-gui', | 31 'node', |
30 'node-event-simulate'], | 32 'node-event-simulate'], |
31 function(Y) { | 33 function(Y) { |
32 juju = Y.namespace('juju'); | 34 juju = Y.namespace('juju'); |
33 models = Y.namespace('juju.models'); | 35 models = Y.namespace('juju.models'); |
34 utils = Y.namespace('juju-tests.utils'); | 36 utils = Y.namespace('juju-tests.utils'); |
35 views = Y.namespace('juju.views'); | 37 views = Y.namespace('juju.views'); |
36 done(); | 38 done(); |
37 }); | 39 }); |
38 }); | 40 }); |
39 | 41 |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
91 serviceModule.dragend(d, serviceModule); | 93 serviceModule.dragend(d, serviceModule); |
92 assert.isFalse(called); | 94 assert.isFalse(called); |
93 location['gui-x'].should.equal(0); | 95 location['gui-x'].should.equal(0); |
94 location['gui-y'].should.equal(0); | 96 location['gui-y'].should.equal(0); |
95 }); | 97 }); |
96 }); | 98 }); |
97 | 99 |
98 describe('service module events', function() { | 100 describe('service module events', function() { |
99 var db, juju, models, serviceModule, topo, utils, | 101 var db, juju, models, serviceModule, topo, utils, |
100 view, viewContainer, views, Y; | 102 view, viewContainer, views, Y; |
103 | |
101 before(function(done) { | 104 before(function(done) { |
102 Y = YUI(GlobalConfig).use(['node', | 105 Y = YUI(GlobalConfig).use(['node', |
103 'juju-tests-utils', | 106 'juju-tests-utils', |
104 'juju-landscape', | 107 'juju-landscape', |
105 'juju-models', | 108 'juju-models', |
106 'juju-views', | 109 'juju-views', |
107 'juju-gui', | 110 'juju-gui', |
108 'node-event-simulate', | 111 'node-event-simulate', |
109 'slider'], | 112 'slider'], |
110 function(Y) { | 113 function(Y) { |
111 juju = Y.namespace('juju'); | 114 juju = Y.namespace('juju'); |
112 models = Y.namespace('juju.models'); | 115 models = Y.namespace('juju.models'); |
113 views = Y.namespace('juju.views'); | 116 views = Y.namespace('juju.views'); |
114 utils = Y.namespace('juju-tests.utils'); | 117 utils = Y.namespace('juju-tests.utils'); |
118 // A global variable required for testing. | |
119 window.flags = {}; | |
115 done(); | 120 done(); |
116 }); | 121 }); |
117 }); | 122 }); |
118 | 123 |
119 beforeEach(function() { | 124 beforeEach(function() { |
120 viewContainer = utils.makeContainer(); | 125 viewContainer = utils.makeContainer(); |
121 db = new models.Database(); | 126 db = new models.Database(); |
122 db.services.add({id: 'haproxy'}); | 127 db.services.add({id: 'haproxy'}); |
123 view = new views.environment({ | 128 view = new views.environment({ |
124 container: viewContainer, | 129 container: viewContainer, |
(...skipping 10 matching lines...) Expand all Loading... | |
135 view.render(); | 140 view.render(); |
136 view.rendered(); | 141 view.rendered(); |
137 topo = view.topo; | 142 topo = view.topo; |
138 serviceModule = topo.modules.ServiceModule; | 143 serviceModule = topo.modules.ServiceModule; |
139 }); | 144 }); |
140 | 145 |
141 afterEach(function() { | 146 afterEach(function() { |
142 if (viewContainer) { | 147 if (viewContainer) { |
143 viewContainer.remove(true); | 148 viewContainer.remove(true); |
144 } | 149 } |
150 }); | |
151 | |
152 after(function() { | |
153 delete window.flags; | |
145 }); | 154 }); |
146 | 155 |
147 it('should toggle the service menu', | 156 it('should toggle the service menu', |
148 function() { | 157 function() { |
149 var box = topo.service_boxes.haproxy; | 158 var box = topo.service_boxes.haproxy; |
150 var menu = viewContainer.one('#service-menu'); | 159 var menu = viewContainer.one('#service-menu'); |
151 assert.isFalse(menu.hasClass('active')); | 160 assert.isFalse(menu.hasClass('active')); |
152 serviceModule.toggleServiceMenu(box); | 161 serviceModule.toggleServiceMenu(box); |
153 assert(menu.hasClass('active')); | 162 assert(menu.hasClass('active')); |
154 serviceModule.toggleServiceMenu(box); | 163 serviceModule.toggleServiceMenu(box); |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
362 | 371 |
363 it('should deploy a service on charm token drop events', function(done) { | 372 it('should deploy a service on charm token drop events', function(done) { |
364 d3.event._event = {dataTransfer: { | 373 d3.event._event = {dataTransfer: { |
365 getData: function(name) { | 374 getData: function(name) { |
366 if (name === 'dataType') { | 375 if (name === 'dataType') { |
367 return 'charm-token-drag-and-drop'; | 376 return 'charm-token-drag-and-drop'; |
368 } else if (name === 'charmData') { | 377 } else if (name === 'charmData') { |
369 return '{"id": "cs:foo/bar-1"}'; | 378 return '{"id": "cs:foo/bar-1"}'; |
370 } | 379 } |
371 }}}; | 380 }}}; |
372 var eventHandle = Y.on('initiateDeploy', function(charm) { | 381 var eventHandle = Y.on('initiateDeploy', function(charm) { |
jeff.pihach
2013/06/24 22:35:08
see previous comment about firing from the topolog
benji
2013/06/25 20:56:36
Done.
| |
373 eventHandle.detach(); | 382 eventHandle.detach(); |
374 done(); | 383 done(); |
375 }); | 384 }); |
376 serviceModule.canvasDropHandler(); | 385 serviceModule.canvasDropHandler(); |
377 }); | 386 }); |
378 | 387 |
379 }); | 388 }); |
LEFT | RIGHT |