Skip to content

Commit 86ff9b9

Browse files
committed
Merge pull request #1 from VisualTesting/tests
Tests
2 parents ebab6ae + ac76517 commit 86ff9b9

8 files changed

Lines changed: 154 additions & 2 deletions

File tree

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
language: node_js
2+
script: "npm run travis"
3+
node_js:
4+
- node
5+
- io.js
6+
- "0.10"
7+
notifications:
8+
email: false

Gruntfile.js

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
'use strict';
2+
3+
module.exports = function(grunt) {
4+
grunt.initConfig({
5+
path_validator: {
6+
js: {
7+
src: [
8+
'**/*[A-Z]*.js',
9+
'!node_modules/**/*.js',
10+
'!Gruntfile.js'
11+
]
12+
}
13+
},
14+
15+
jscs: {
16+
files: {
17+
src: [
18+
'**/*.js',
19+
'!node_modules/**'
20+
]
21+
}
22+
},
23+
24+
jshint: {
25+
options: {
26+
jshintrc: true
27+
},
28+
files: {
29+
src: [
30+
'**/*.js',
31+
'!node_modules/**'
32+
]
33+
}
34+
}
35+
});
36+
37+
require('load-grunt-tasks')(grunt);
38+
39+
grunt.registerTask('style', ['path_validator', 'jshint', 'jscs']);
40+
};

package.json

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,22 @@
1010
},
1111
"devDependencies": {
1212
"coveralls": "^2.11.2",
13+
"grunt": "^0.4.5",
14+
"grunt-cli": "^0.1.13",
15+
"grunt-contrib-jshint": "^0.11.1",
16+
"grunt-jscs": "^1.6.0",
17+
"grunt-path-validator": "^1.0.1",
1318
"istanbul": "^0.3.13",
14-
"jscs": "^1.12.0",
15-
"jshint": "^2.6.3",
19+
"load-grunt-tasks": "^3.1.0",
1620
"mocha": "^2.2.1",
1721
"mocha-sinon": "^1.1.4",
1822
"sinon": "^1.14.1"
23+
},
24+
"engines": {
25+
"node": ">=0.8.0"
26+
},
27+
"scripts": {
28+
"test": "grunt style && mocha --color",
29+
"travis": "grunt style && istanbul cover ./node_modules/mocha/bin/_mocha --report lcovonly -- -R spec && cat ./coverage/lcov.info | coveralls && rm -rf ./coverage"
1930
}
2031
}

stash.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,4 +96,8 @@ StashService.prototype = {
9696
}
9797
};
9898

99+
if (process.env.NODE_ENV === 'test') {
100+
StashService.prototype.verifyConfig = verifyConfig;
101+
}
102+
99103
module.exports = StashService;

test/.jshintrc

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"extends": "../.jshintrc",
3+
"mocha": true,
4+
"globals": {
5+
"assert": false
6+
}
7+
}

test/mocha.opts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
test/*.js
2+
-R dot
3+
-u bdd
4+
--require test/support/setup

test/stash-test.js

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
'use strict';
2+
3+
var StashService = require('../stash');
4+
5+
describe('module/stash', function() {
6+
var stashService;
7+
var options;
8+
9+
beforeEach(function() {
10+
options = {
11+
url: 'url',
12+
user: 'user',
13+
password: 'password'
14+
};
15+
});
16+
17+
describe('constructor', function() {
18+
describe('with invalid args', function() {
19+
it('throws with non object', function() {
20+
assert.throws(function() {
21+
stashService = new StashService();
22+
});
23+
24+
assert.throws(function() {
25+
stashService = new StashService('foo');
26+
});
27+
});
28+
29+
describe('throws without', function() {
30+
afterEach(function() {
31+
assert.throws(function() {
32+
stashService = new StashService(options);
33+
});
34+
});
35+
36+
it('url', function() {
37+
delete options.url;
38+
});
39+
40+
it('user', function() {
41+
delete options.user;
42+
});
43+
44+
it('user', function() {
45+
delete options.user;
46+
});
47+
});
48+
49+
it('does not throw with all args', function() {
50+
assert.doesNotThrow(function() {
51+
stashService = new StashService(options);
52+
});
53+
});
54+
});
55+
});
56+
57+
describe('functions', function() {
58+
beforeEach(function() {
59+
stashService = new StashService(options);
60+
});
61+
62+
it('#serviceKey is stash', function() {
63+
assert.equal(stashService.serviceKey, 'stash');
64+
});
65+
});
66+
});

test/support/setup.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
'use strict';
2+
3+
process.env.NODE_ENV = 'test';
4+
5+
var chai = require('chai');
6+
7+
var sinon = require('sinon');
8+
sinon.assert.expose(chai.assert, {
9+
prefix: ''
10+
});
11+
12+
global.assert = chai.assert;

0 commit comments

Comments
 (0)