Skip to content

Commit

Permalink
Merge pull request clientIO#233 from chill117/fix-code-styling-env-tests
Browse files Browse the repository at this point in the history
Fixes for JSCS in joint.env tests
  • Loading branch information
kumilingus committed Feb 5, 2016
2 parents e364cf8 + 5562c82 commit 59328b1
Showing 1 changed file with 29 additions and 29 deletions.
58 changes: 29 additions & 29 deletions test/jointjs/env.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,45 +2,45 @@

QUnit.module('joint.env', function(hooks) {

QUnit.test('addTest(name, fn)', function(assert) {
QUnit.test('addTest(name, fn)', function(assert) {

assert.equal(typeof joint.env.addTest, 'function', 'should be a function');
assert.equal(typeof joint.env.addTest, 'function', 'should be a function');

var testFn = function() {
return true;
};
var testFn = function() {
return true;
};

joint.env.addTest('custom1', testFn);
joint.env.addTest('custom1', testFn);

assert.equal(joint.env._tests['custom1'], testFn, 'should be able to add a test');
});
assert.equal(joint.env._tests['custom1'], testFn, 'should be able to add a test');
});

QUnit.test('test(name)', function(assert) {
QUnit.test('test(name)', function(assert) {

assert.equal(typeof joint.env.test, 'function', 'should be a function');
assert.equal(typeof joint.env.test, 'function', 'should be a function');

assert.throws(
function() {
joint.env.test('does_not_exist')
},
new Error('Test not defined ("does_not_exist"). Use `joint.env.addTest(name, fn) to add a new test.`'),
'should throw error if test does not exist'
);
assert.throws(
function() {
joint.env.test('does_not_exist');
},
new Error('Test not defined ("does_not_exist"). Use `joint.env.addTest(name, fn) to add a new test.`'),
'should throw error if test does not exist'
);

var numCalls = 0;
var numCalls = 0;

joint.env._tests['custom1'] = function() {
numCalls++;
return true;
};
joint.env._tests['custom1'] = function() {
numCalls++;
return true;
};

assert.ok(joint.env.test('custom1') && numCalls === 1, 'should run the test function');
assert.ok(joint.env.test('custom1') && numCalls === 1, 'should only run the test function once');
assert.ok(joint.env.test('custom1') && numCalls === 1, 'should run the test function');
assert.ok(joint.env.test('custom1') && numCalls === 1, 'should only run the test function once');

joint.env._tests['throws_error'] = function() {
throw new Error('Testing thrown error');
};
joint.env._tests['throws_error'] = function() {
throw new Error('Testing thrown error');
};

assert.notOk(joint.env.test('throws_error'), 'should catch thrown error and return false');
});
assert.notOk(joint.env.test('throws_error'), 'should catch thrown error and return false');
});
});

0 comments on commit 59328b1

Please sign in to comment.