Skip to content

Commit f42652b

Browse files
committed
Add unittest framework.
* TODO: more UT cases. Signed-off-by: Eric Wang <[email protected]>
1 parent d58eee0 commit f42652b

File tree

4 files changed

+26
-3
lines changed

4 files changed

+26
-3
lines changed

.travis.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ language: node_js
22
node_js:
33
- stable
44
install:
5-
- npm install -g eslint-cli
5+
- npm install -g eslint-cli mocha
66
- npm install

lib/helper.js

+1
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ h.getSetCookieValue = function(resp, key) {
8585
if (kv[0] === key) return kv[1];
8686
}
8787
}
88+
return null;
8889
};
8990

9091
module.exports = h;

package.json

+4-2
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"lc": "./bin/lc"
88
},
99
"scripts": {
10-
"test": "npm run lint",
10+
"test": "npm run lint && mocha test/",
1111
"lint": "eslint lib/"
1212
},
1313
"repository": {
@@ -38,7 +38,9 @@
3838
"yargs": "^5.0.0"
3939
},
4040
"devDependencies": {
41+
"chai": "^3.5.0",
4142
"eslint": "^3.3.1",
42-
"eslint-config-google": "^0.6.0"
43+
"eslint-config-google": "^0.6.0",
44+
"mocha": "^3.0.2"
4345
}
4446
}

test/test_helper.js

+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
var assert = require('chai').assert;
2+
3+
var h = require('../lib/helper');
4+
5+
describe('helper', function() {
6+
describe('#getSetCookieValue', function() {
7+
it('should ok', function() {
8+
var resp = {
9+
headers: {'set-cookie': [
10+
'key1=value1; path=/; Httponly',
11+
'key2=value2; path=/; Httponly']
12+
}
13+
};
14+
15+
assert.equal(h.getSetCookieValue(resp, 'key1'), 'value1');
16+
assert.equal(h.getSetCookieValue(resp, 'key2'), 'value2');
17+
assert.equal(h.getSetCookieValue(resp, 'key3'), null);
18+
});
19+
});
20+
});

0 commit comments

Comments
 (0)