~hatch/juju-gui/1132943-scaffold

« back to all changes in this revision

Viewing changes to test/test_landscape.js

  • Committer: Jeff Pihach
  • Date: 2013-03-04 15:24:46 UTC
  • mfrom: (406.3.6 juju-gui)
  • Revision ID: jeff.pihach@canonical.com-20130304152446-o2abulrzk9l3p24c
merged trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
describe('Landscape integration', function() {
4
4
 
5
 
  var views, models, db, landscape;
 
5
  var views, models, db, landscape, Y;
6
6
 
7
7
  before(function(done) {
8
 
    YUI(GlobalConfig).use(['juju-landscape',
9
 
                           'juju-models',
10
 
                           'juju-views'], function(Y) {
 
8
    Y = YUI(GlobalConfig).use(['node',
 
9
      'juju-landscape',
 
10
      'juju-models',
 
11
      'juju-views'], function(Y) {
11
12
      var envAnno;
12
13
 
13
14
      views = Y.namespace('juju.views');
126
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
});