Skip to content

Commit

Permalink
Fix code style
Browse files Browse the repository at this point in the history
  • Loading branch information
benurb committed Nov 15, 2014
1 parent 2e80b4e commit c4f1144
Show file tree
Hide file tree
Showing 6 changed files with 56 additions and 30 deletions.
6 changes: 3 additions & 3 deletions test/lib/command/domid/domid.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ describe('domid', function () {
});

it('should throw error when invoking without callback', function () {
expect(function() {
xl.domid({})
expect(function () {
xl.domid({});
}).to.throw('without callback');
});

Expand All @@ -107,7 +107,7 @@ describe('domid', function () {
}, function (err, data) {
expect(err).to.be.an.instanceof(Error);
expect(err.message).to.contain('not connect');
expect(data).to.be.undefined;
expect(data).to.be.undefined();

done();
});
Expand Down
6 changes: 3 additions & 3 deletions test/lib/command/domname/domname.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ describe('domid', function () {
});

it('should throw error when invoking without callback', function () {
expect(function() {
xl.domname({})
expect(function () {
xl.domname({});
}).to.throw('without callback');
});

Expand All @@ -107,7 +107,7 @@ describe('domid', function () {
}, function (err, data) {
expect(err).to.be.an.instanceof(Error);
expect(err.message).to.contain('not connect');
expect(data).to.be.undefined;
expect(data).to.be.undefined();

done();
});
Expand Down
4 changes: 2 additions & 2 deletions test/lib/command/list/list.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('list', function () {
xl.list({}, function (err, data) {
expect(err).to.be.an.instanceof(Error);
expect(err.message).to.contain('not found');
expect(data).to.be.undefined;
expect(data).to.be.undefined();

done();
});
Expand All @@ -72,7 +72,7 @@ describe('list', function () {
xl.list({}, function (err, data) {
expect(err).to.be.an.instanceof(Error);
expect(err.message).to.contain('not connect');
expect(data).to.be.undefined;
expect(data).to.be.undefined();

done();
});
Expand Down
28 changes: 18 additions & 10 deletions test/lib/index.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,17 @@ var expect = require('chai').expect,
XL = require('../../lib');

describe('XL', function () {
it('should succeed if executorName is defined, but not executorOptions', function() {
'use strict';

it('should succeed if executorName is defined, but not executorOptions', function () {
var xl = new XL({
'executorName': 'dummy'
});

expect(xl).to.be.an.instanceof(XL);
});

it('should not filter if no filter is defined', function() {
it('should not filter if no filter is defined', function () {
var xl = new XL({
'executorName': 'dummy'
});
Expand All @@ -21,7 +23,7 @@ describe('XL', function () {
expect(xl.filter('yourvm')).to.eql(true);
});

it('should apply string filter correctly', function() {
it('should apply string filter correctly', function () {
var xl = new XL({
'executorName': 'dummy',
'filter': 'myvm'
Expand All @@ -33,7 +35,7 @@ describe('XL', function () {
expect(xl.filter('yourvm')).to.eql(false);
});

it('should use configFileTemplate if defined', function() {
it('should use configFileTemplate if defined', function () {
var tpl = '/etc/tpl/{{name}}.cfg';
var xl = new XL({
'executorName': 'dummy',
Expand All @@ -44,25 +46,31 @@ describe('XL', function () {
expect(xl.configFileTemplate).to.eql(tpl);
});

it('should fail if options are missing', function() {
it('should fail if options are missing', function () {
expect(function () {
new XL();
var xl = new XL();
// Prevent jshint warnings
xl = xl;
}).to.throw('without executor');
});

it('should fail if executorName property is missing in options', function() {
it('should fail if executorName property is missing in options', function () {
expect(function () {
new XL({
var xl = new XL({
'name': 'dummy'
});
// Prevent jshint warnings
xl = xl;
}).to.throw('without executor');
});

it('should fail if executor does not exist', function() {
it('should fail if executor does not exist', function () {
expect(function () {
new XL({
var xl = new XL({
'executorName': 'dummy-fail'
});
// Prevent jshint warnings
xl = xl;
}).to.throw('Cannot find executor');
});
});
32 changes: 23 additions & 9 deletions test/util/altproperty.test.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
var expect = require('chai').expect
var expect = require('chai').expect,
altproperty = require('../../util/altproperty');

describe('altproperty', function () {
'use strict';

var obj;

beforeEach(function() {
beforeEach(function () {
obj = {
'name': 'n',
'domName': 'dN',
Expand All @@ -13,7 +15,7 @@ describe('altproperty', function () {
});

it('should not change anything if destination property is already present', function () {
expect(altproperty(obj, 'name', ['domainName', 'domName'])).to.eql(obj);
expect(altproperty(obj, 'name', ['domainName', 'domName'])).to.deep.equal(obj);
});

it('should use the first alt name if destination property does not exist', function () {
Expand All @@ -24,7 +26,7 @@ describe('altproperty', function () {
'domainName': 'domainN'
};

expect(altproperty(obj, 'name2', ['domainName', 'domName'])).to.eql(obj);
expect(altproperty(obj, 'name2', ['domainName', 'domName'])).to.deep.equal(destObj);
});

it('should not use alt names that do not exist', function () {
Expand All @@ -35,22 +37,34 @@ describe('altproperty', function () {
'domainName': 'domainN'
};

expect(altproperty(obj, 'name2', ['dName', 'doName', 'domainName', 'domName'])).to.eql(obj);
expect(altproperty(obj, 'name2', ['dName', 'doName', 'domainName', 'domName'])).to.deep.equal(destObj);
});

it('should fail if missing all parameters', function () {
expect(altproperty()).to.be.undefined;
expect(altproperty()).to.be.undefined();
});

it('should fail if missing destination property and alt names', function () {
expect(altproperty({'a': 1})).to.eql({'a': 1});
expect(altproperty({
'a': 1
})).to.deep.equal({
'a': 1
});
});

it('should fail if missing alt names', function () {
expect(altproperty({'a': 1}, 'b')).to.eql({'a': 1});
expect(altproperty({
'a': 1
}, 'b')).to.deep.equal({
'a': 1
});
});

it('should fail if alt names is not an array', function () {
expect(altproperty({'a': 1}, 'b', 'c')).to.eql({'a': 1});
expect(altproperty({
'a': 1
}, 'b', 'c')).to.deep.equal({
'a': 1
});
});
});
10 changes: 7 additions & 3 deletions test/util/sanitize.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
var expect = require('chai').expect
var expect = require('chai').expect,
sanitize = require('../../util/sanitize');

describe('sanitize', function () {
'use strict';

describe('domName', function () {
it('should not change a valid name', function () {
var name = 'thisismyname12345';
Expand All @@ -21,7 +23,7 @@ describe('sanitize', function () {
});
});

describe('domId', function() {
describe('domId', function () {
it('should accept an id as number', function () {
expect(sanitize.domId(100)).to.eql(100);
});
Expand Down Expand Up @@ -51,7 +53,9 @@ describe('sanitize', function () {
});

it('should reject an object', function () {
expect(sanitize.domId({'a': 100})).to.eql('');
expect(sanitize.domId({
'a': 100
})).to.eql('');
});

it('should reject an array with a string on top', function () {
Expand Down

0 comments on commit c4f1144

Please sign in to comment.