OLD | NEW |
1 'use strict'; | 1 'use strict'; |
2 | 2 |
3 describe('Landscape integration', function() { | 3 describe('Landscape integration', function() { |
4 | 4 |
5 var views, models, db, landscape; | 5 var views, models, db, landscape, Y; |
6 | 6 |
7 before(function(done) { | 7 before(function(done) { |
8 YUI(GlobalConfig).use(['juju-landscape', | 8 Y = YUI(GlobalConfig).use(['node', |
9 'juju-models', | 9 'juju-landscape', |
10 'juju-views'], function(Y) { | 10 'juju-models', |
| 11 'juju-views'], function(Y) { |
11 var envAnno; | 12 var envAnno; |
12 | 13 |
13 views = Y.namespace('juju.views'); | 14 views = Y.namespace('juju.views'); |
14 models = Y.namespace('juju.models'); | 15 models = Y.namespace('juju.models'); |
15 | 16 |
16 db = new models.Database(); | 17 db = new models.Database(); |
17 landscape = new views.Landscape(); | 18 landscape = new views.Landscape(); |
18 landscape.set('db', db); | 19 landscape.set('db', db); |
19 | 20 |
20 // Set defaults for testing. | 21 // Set defaults for testing. |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
119 landscape.update(); | 120 landscape.update(); |
120 env['landscape-security-upgrades'].should.equal(true); | 121 env['landscape-security-upgrades'].should.equal(true); |
121 | 122 |
122 // ... and wordpress. | 123 // ... and wordpress. |
123 wordpress['landscape-security-upgrades'].should.equal(true); | 124 wordpress['landscape-security-upgrades'].should.equal(true); |
124 | 125 |
125 // But mysql is still not flagged. | 126 // But mysql is still not flagged. |
126 mysql['landscape-security-upgrades'].should.equal(false); | 127 mysql['landscape-security-upgrades'].should.equal(false); |
127 }); | 128 }); |
128 | 129 |
| 130 it('should build the bottom-bar properly', function() { |
| 131 var env = db.environment; |
| 132 var mysql = db.services.getById('mysql'); |
| 133 var unit = db.units.item(0); |
| 134 var partial = Y.Handlebars.partials['landscape-controls']; |
| 135 Y.one('body').append('<div id="test-node"></div>'); |
| 136 var node = Y.one('#test-node'); |
| 137 node.append(partial()); |
| 138 |
| 139 views.utils.updateLandscapeBottomBar(landscape, env, env, node, |
| 140 'environment'); |
| 141 |
| 142 // We should have the correct logo. |
| 143 node.one('.logo-tab i').hasClass('landscape_environment') |
| 144 .should.equal(true); |
| 145 // We should have the correct URL for the machines. |
| 146 node.one('.machine-control a').get('href').should |
| 147 .equal('http://landscape.com/computers/criteria/environment:test/'); |
| 148 // We should have visible controls. |
| 149 node.one('.updates-control').getStyle('display').should.equal('block'); |
| 150 node.one('.restart-control').getStyle('display').should.equal('block'); |
| 151 |
| 152 views.utils.updateLandscapeBottomBar(landscape, env, mysql, node, |
| 153 'service'); |
| 154 |
| 155 // We should have the correct logo. |
| 156 node.one('.logo-tab i').hasClass('landscape_service') |
| 157 .should.equal(true); |
| 158 // We should have the correct URL for the machines. |
| 159 node.one('.machine-control a').get('href').should.equal('http://' + |
| 160 'landscape.com/computers/criteria/environment:test+service:mysql/'); |
| 161 // We should have visible restart but not update controls. |
| 162 node.one('.updates-control').getStyle('display').should.equal('none'); |
| 163 node.one('.restart-control').getStyle('display').should.equal('block'); |
| 164 |
| 165 unit.annotations = {'landscape-computer': '+unit:mysql-0'}; |
| 166 landscape.update(); |
| 167 |
| 168 views.utils.updateLandscapeBottomBar(landscape, env, unit, node, |
| 169 'unit'); |
| 170 |
| 171 // We should have the correct logo. |
| 172 node.one('.logo-tab i').hasClass('landscape_unit') |
| 173 .should.equal(true); |
| 174 // We should have the correct URL for the machines. |
| 175 node.one('.machine-control a').get('href').should.equal('http://' + |
| 176 'landscape.com/computers/criteria/environment:test+unit:mysql-0/'); |
| 177 // We should have no visible controls. |
| 178 node.one('.updates-control').getStyle('display').should.equal('none'); |
| 179 node.one('.restart-control').getStyle('display').should.equal('none'); |
| 180 |
| 181 node.remove(); |
| 182 }); |
| 183 |
129 }); | 184 }); |
OLD | NEW |