Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(41)

Side by Side Diff: test/test_utils.js

Issue 14033043: Fix settings emptied out on save.
Patch Set: Fix settings emptied out on save. Created 11 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « test/test_env_go.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
(...skipping 267 matching lines...) Expand 10 before | Expand all | Expand 10 after
278 assert.strictEqual('mysql', result.near.service, 'near service'); 278 assert.strictEqual('mysql', result.near.service, 'near service');
279 assert.strictEqual('provider', result.near.role, 'near role'); 279 assert.strictEqual('provider', result.near.role, 'near role');
280 assert.strictEqual('mydb', result.near.name, 'near name'); 280 assert.strictEqual('mydb', result.near.name, 'near name');
281 assert.strictEqual('mediawiki', result.far.service, 'far service'); 281 assert.strictEqual('mediawiki', result.far.service, 'far service');
282 assert.strictEqual('requirer', result.far.role, 'far role'); 282 assert.strictEqual('requirer', result.far.role, 'far role');
283 assert.strictEqual('db', result.far.name, 'far name'); 283 assert.strictEqual('db', result.far.name, 'far name');
284 }); 284 });
285 285
286 }); 286 });
287 287
288 describe('getChangedConfigOptions', function() {
289 var getChangedConfigOptions;
290
291 before(function() {
292 getChangedConfigOptions = utils.getChangedConfigOptions;
293 });
294
295 it('returns undefined if no config options are provided', function() {
296 assert.isUndefined(getChangedConfigOptions(null, {}));
297 });
298
299 it('returns an empty object if an empty config is provided', function() {
300 var newValues = getChangedConfigOptions({}, {foo: 'bar'});
301 assert.deepEqual(newValues, {});
302 });
303
304 it('returns an empty object if no service changes are found', function() {
305 var newValues = getChangedConfigOptions({foo: 'bar'}, {foo: 'bar'});
306 assert.deepEqual(newValues, {});
307 });
308
309 it('returns an empty object if no charm changes are found', function() {
310 var charmConfig = {foo: {default: 'bar'}};
311 var newValues = getChangedConfigOptions({foo: 'bar'}, charmConfig);
312 assert.deepEqual(newValues, {});
313 });
314
315 it('returns changes if they are found on the service', function() {
316 var serviceConfig = {
317 key1: 'value1',
318 key2: 'value2',
319 key3: true,
320 key4: false,
321 key5: 5,
322 key6: 6
323 };
324 var newConfig = {
325 key1: 'value1',
326 key2: 'CHANGED!',
327 key3: true,
328 key4: true,
329 key5: 5,
330 key6: 42
331 };
332 var newValues = getChangedConfigOptions(newConfig, serviceConfig);
333 assert.deepEqual(newValues, {key2: 'CHANGED!', key4: true, key6: 42});
334 });
335
336 it('returns changes if they are found on the charm', function() {
337 var charmConfig = {
338 key1: {default: 'value1'},
339 key2: {default: 'value2'},
340 key3: {default: true},
341 key4: {default: false},
342 key5: {default: 5},
343 key6: {default: 6}
344 };
345 var newConfig = {
346 key1: 'value1',
347 key2: 'CHANGED!',
348 key3: true,
349 key4: true,
350 key5: 5,
351 key6: 42
352 };
353 var newValues = getChangedConfigOptions(newConfig, charmConfig);
354 assert.deepEqual(newValues, {key2: 'CHANGED!', key4: true, key6: 42});
355 });
356
357 it('returns all the changes if the existing config is empty', function() {
358 var newValues = getChangedConfigOptions({key1: 'value', key2: 42}, {});
359 assert.deepEqual(newValues, {key1: 'value', key2: 42});
360 });
361
362 it('does not modify in place the passed new config object', function() {
363 var newConfig = {key1: 'CHANGED!', key2: 42};
364 getChangedConfigOptions(newConfig, {key1: 'value', key2: 42});
365 assert.deepEqual(newConfig, {key1: 'CHANGED!', key2: 42});
366 });
367
368 it('does not modify in place the passed existing config', function() {
369 var serviceConfig = {key1: 'value', key2: 42};
370 getChangedConfigOptions({key1: 'CHANGED!', key2: 42}, serviceConfig);
371 assert.deepEqual(serviceConfig, {key1: 'value', key2: 42});
372 });
373
374 });
375
288 }); 376 });
289 377
290 (function() { 378 (function() {
291 describe('form validation', function() { 379 describe('form validation', function() {
292 380
293 var utils, Y; 381 var utils, Y;
294 382
295 before(function(done) { 383 before(function(done) {
296 Y = YUI(GlobalConfig).use('juju-views', 384 Y = YUI(GlobalConfig).use('juju-views',
297 385
(...skipping 856 matching lines...) Expand 10 before | Expand all | Expand 10 after
1154 var url = utils.getLandscapeURL(environment, unit, 'security'); 1242 var url = utils.getLandscapeURL(environment, unit, 'security');
1155 var expected = makeURL( 1243 var expected = makeURL(
1156 '+unit:django-42/+alert:security-upgrades/packages/list' + 1244 '+unit:django-42/+alert:security-upgrades/packages/list' +
1157 '?filter=security'); 1245 '?filter=security');
1158 assert.strictEqual(url, expected); 1246 assert.strictEqual(url, expected);
1159 }); 1247 });
1160 1248
1161 }); 1249 });
1162 1250
1163 })(); 1251 })();
OLDNEW
« no previous file with comments | « test/test_env_go.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b