Left: | ||
Right: |
OLD | NEW |
---|---|
(Empty) | |
1 /* | |
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). | |
4 Copyright (C) 2013 Canonical Ltd. | |
5 | |
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 | |
8 the Free Software Foundation. | |
9 | |
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, | |
12 SATISFACTORY QUALITY, or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero | |
13 General Public License for more details. | |
14 | |
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/>. | |
17 */ | |
18 'use strict'; | |
19 | |
20 describe('Inspector Settings', function() { | |
21 | |
22 var view, service, db, models, utils, juju, env, conn, container, | |
23 inspector, Y, jujuViews, exposeCalled, unexposeCalled; | |
24 var charmConfig = | |
25 { config: | |
26 { options: | |
27 { option0: | |
28 { name: 'option0', | |
29 type: 'string', | |
30 description: 'Option Zero'}, | |
31 option1: | |
32 { name: 'option1', | |
33 type: 'boolean', | |
34 description: 'Option One'}, | |
35 option2: | |
36 { name: 'option2', | |
37 type: 'int', | |
38 description: 'Option Two'} } | |
39 } | |
40 }; | |
41 | |
42 before(function(done) { | |
43 var requires = ['juju-gui', 'juju-views', 'juju-tests-utils']; | |
44 Y = YUI(GlobalConfig).use(requires, function(Y) { | |
45 utils = Y.namespace('juju-tests.utils'); | |
46 models = Y.namespace('juju.models'); | |
47 jujuViews = Y.namespace('juju.views'); | |
48 juju = Y.namespace('juju'); | |
49 done(); | |
50 }); | |
51 | |
52 }); | |
53 | |
54 beforeEach(function() { | |
55 exposeCalled = false; | |
56 unexposeCalled = false; | |
57 container = Y['juju-tests'].utils.makeContainer('container'); | |
jeff.pihach
2013/07/05 19:39:13
just utils.makeContainer()
bac
2013/07/05 20:57:07
Done.
| |
58 conn = new utils.SocketStub(); | |
59 db = new models.Database(); | |
60 env = juju.newEnvironment({conn: conn}); | |
61 env.expose = function(service) { | |
62 exposeCalled = true; | |
63 }; | |
64 env.unexpose = function(service) { | |
65 unexposeCalled = true; | |
66 }; | |
67 }); | |
68 | |
69 afterEach(function() { | |
jeff.pihach
2013/07/05 19:39:13
I am pretty sure we also want to destroy the envir
bac
2013/07/05 20:57:07
Done.
| |
70 if (view) { | |
71 if (inspector) { | |
72 view.setInspector(inspector, true); | |
73 } | |
74 view.destroy(); | |
75 } | |
76 container.remove(true); | |
77 }); | |
78 | |
79 var setUpInspector = function() { | |
80 var charmId = 'precise/mediawiki-4'; | |
81 var charm = new models.Charm({id: charmId}); | |
82 charm.setAttrs(charmConfig); | |
83 db.charms.add(charm); | |
84 service = new models.Service({ | |
85 id: 'mediawiki', | |
86 charm: charmId, | |
87 exposed: false}); | |
88 view = new jujuViews.environment({ | |
89 container: container, | |
90 db: db, | |
91 env: env | |
92 }); | |
93 view.render(); | |
94 Y.Node.create([ | |
95 '<div id="content">' | |
96 ].join('')).appendTo(container); | |
97 view.createServiceInspector(service, {}); | |
98 return view.getInspector(service.get('id')); | |
99 }; | |
100 | |
101 it('creates a ServiceInspector', function() { | |
102 inspector = setUpInspector(); | |
103 assert.isFalse(service.get('exposed')); | |
jeff.pihach
2013/07/05 19:39:13
This isn't really testing that a service inspector
bac
2013/07/05 20:57:07
No, it was useful when developing the test but no
| |
104 }); | |
105 | |
106 | |
107 it('toggles exposure', function() { | |
108 inspector = setUpInspector(); | |
109 assert.isFalse(service.get('exposed')); | |
110 assert.isFalse(exposeCalled); | |
111 assert.isFalse(unexposeCalled); | |
112 var expose = container.one('.toggle-expose'); | |
113 expose.simulate('click'); | |
114 assert.isTrue(service.get('exposed')); | |
115 assert.isTrue(exposeCalled); | |
116 assert.isFalse(unexposeCalled); | |
117 | |
118 expose.simulate('click'); | |
119 assert.isTrue(unexposeCalled); | |
120 assert.isFalse(service.get('exposed')); | |
121 }); | |
122 | |
123 }); | |
OLD | NEW |