OLD | NEW |
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('bundle module', function() { | 21 describe('bundle module', function() { |
22 var db, juju, models, utils, views, Y, bundleModule; | 22 var juju, models, utils, views, Y, bundleModule; |
23 var bundle, container, fakeStore; | 23 var bundle, container, fakebackend; |
24 | 24 |
25 before(function(done) { | 25 before(function(done) { |
26 Y = YUI(GlobalConfig).use([ | 26 Y = YUI(GlobalConfig).use([ |
27 'juju-topology', | 27 'juju-topology', |
28 'juju-view-bundle', | 28 'juju-view-bundle', |
29 'juju-charm-store', | 29 'juju-charm-store', |
30 'juju-models', | 30 'juju-models', |
31 'juju-tests-utils' | 31 'juju-tests-utils' |
32 ], | 32 ], |
33 function(Y) { | 33 function(Y) { |
34 juju = Y.namespace('juju'); | 34 juju = Y.namespace('juju'); |
35 models = Y.namespace('juju.models'); | 35 models = Y.namespace('juju.models'); |
36 utils = Y.namespace('juju-tests.utils'); | 36 utils = Y.namespace('juju-tests.utils'); |
37 views = Y.namespace('juju.views'); | 37 views = Y.namespace('juju.views'); |
38 done(); | 38 done(); |
39 }); | 39 }); |
40 }); | 40 }); |
41 | 41 |
42 beforeEach(function() { | 42 beforeEach(function() { |
43 container = utils.makeContainer(); | 43 container = utils.makeContainer(); |
44 db = new models.Database(); | |
45 }); | 44 }); |
46 | 45 |
47 afterEach(function() { | 46 afterEach(function() { |
48 if (container) { container.remove(true); } | 47 if (container) { container.remove(true); } |
49 if (bundle) { bundle.destroy(); } | 48 if (bundle) { bundle.destroy(); } |
50 | 49 |
51 }); | 50 }); |
52 | 51 |
53 function promiseBundle() { | 52 function promiseBundle(done) { |
54 db.environment.set('defaultSeries', 'precise'); | 53 fakebackend = utils.makeFakeBackend(); |
55 var fakeStore = utils.makeFakeStore(db.charms); | 54 fakebackend.db.environment.set('defaultSeries', 'precise'); |
56 fakeStore.iconpath = function() { return 'fake.svg'; }; | |
57 | 55 |
58 return db.importDeployer( | 56 return fakebackend.promiseImport( |
59 jsyaml.safeLoad(utils.loadFixture('data/wp-deployer.yaml')), | 57 utils.loadFixture('data/wp-deployer.yaml'), |
60 fakeStore, {useGhost: true, targetBundle: 'wordpress-prod'}) | 58 'wordpress-prod') |
61 .then(function() { | 59 .then(function() { |
62 bundle = new views.BundleTopology({ | 60 bundle = new views.BundleTopology({ |
63 db: db, | 61 db: fakebackend.db, |
64 container: container, | 62 container: container, |
65 store: fakeStore | 63 store: fakebackend.get('store') |
66 }).render(); | 64 }).render(); |
67 bundleModule = bundle.topology.modules.BundleModule; | 65 bundleModule = bundle.topology.modules.BundleModule; |
68 bundleModule.set('useTransitions', false); | 66 bundleModule.set('useTransitions', false); |
69 return bundle; | 67 return bundle; |
70 }); | 68 }, done); |
71 } | 69 } |
72 | 70 |
73 function normalizeTranslate(translateStr) { | 71 function normalizeTranslate(translateStr) { |
74 return translateStr.replace(',', ' '); | 72 return translateStr.replace(',', ' '); |
75 } | 73 } |
76 | 74 |
77 it('should create a proper service for each model', function(done) { | 75 it('should create a proper service for each model', function(done) { |
78 promiseBundle() | 76 promiseBundle(done) |
79 .then(function(bundle) { | 77 .then(function(bundle) { |
80 // The size of the element should reflect the passed in params | 78 // The size of the element should reflect the passed in params |
81 var selection = d3.select(container.getDOMNode()); | 79 var selection = d3.select(container.getDOMNode()); |
82 var svg = selection.select('svg'); | 80 var svg = selection.select('svg'); |
83 assert.equal(svg.attr('width'), 640); | 81 assert.equal(svg.attr('width'), 640); |
84 assert.equal(svg.attr('height'), 480); | 82 assert.equal(svg.attr('height'), 480); |
85 | 83 |
86 // We should have the two rendered services | 84 // We should have the two rendered services |
87 assert.equal(container.all('.service').size(), 2); | 85 assert.equal(container.all('.service').size(), 2); |
88 assert.deepEqual(container.all('tspan.name').get('text'), [ | 86 assert.deepEqual(container.all('tspan.name').get('text'), [ |
(...skipping 15 matching lines...) Expand all Loading... |
104 assert.equal(indicator.attr('y'), '64'); | 102 assert.equal(indicator.attr('y'), '64'); |
105 | 103 |
106 container.remove(true); | 104 container.remove(true); |
107 bundle.destroy(); | 105 bundle.destroy(); |
108 done(); | 106 done(); |
109 }).then(undefined, done); | 107 }).then(undefined, done); |
110 }); | 108 }); |
111 | 109 |
112 }); | 110 }); |
113 | 111 |
OLD | NEW |