Skip to content

Commit 4594467

Browse files
committed
add more test cases
1 parent 8619bb4 commit 4594467

5 files changed

Lines changed: 32 additions & 18 deletions

File tree

.travis.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
language: node_js
22
node_js:
3-
- 0.11
4-
- 0.10
53
- 0.8
6-
- 0.6
4+
- '0.10'
5+
- '0.11'
6+
script: make test-coveralls

Makefile

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TESTS = test/*.test.js
22
REPORTER = spec
33
TIMEOUT = 1000
4-
JSCOVERAGE = ./node_modules/jscover/bin/jscover
4+
MOCHA_OPTS =
55

66
install:
77
@npm install
@@ -10,14 +10,20 @@ test: install
1010
@NODE_ENV=test ./node_modules/mocha/bin/mocha \
1111
--reporter $(REPORTER) \
1212
--timeout $(TIMEOUT) \
13+
$(MOCHA_OPTS) \
1314
$(TESTS)
1415

15-
test-cov: install lib-cov
16-
@UTILITY_COV=1 $(MAKE) test REPORTER=dot
17-
@UTILITY_COV=1 $(MAKE) test REPORTER=html-cov > coverage.html
16+
test-cov:
17+
@rm -f coverage.html
18+
@$(MAKE) test MOCHA_OPTS='--require blanket' REPORTER=html-cov > coverage.html
19+
@$(MAKE) test MOCHA_OPTS='--require blanket' REPORTER=travis-cov
20+
@ls -lh coverage.html
1821

19-
lib-cov:
20-
@rm -rf $@
21-
@$(JSCOVERAGE) lib $@
22+
test-coveralls:
23+
@$(MAKE) test
24+
@echo TRAVIS_JOB_ID $(TRAVIS_JOB_ID)
25+
@$(MAKE) test MOCHA_OPTS='--require blanket' REPORTER=mocha-lcov-reporter | ./node_modules/coveralls/bin/coveralls.js
2226

23-
.PHONY: install test test-cov lib-cov
27+
test-all: test test-cov
28+
29+
.PHONY: test test-cov test-all test-coveralls

README.md

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
utility [![Build Status](https://secure.travis-ci.org/fengmk2/utility.png)](http://travis-ci.org/fengmk2/utility)
1+
utility [![Build Status](https://secure.travis-ci.org/fengmk2/utility.png)](http://travis-ci.org/fengmk2/utility) [![Coverage Status](https://coveralls.io/repos/fengmk2/utility/badge.png)](https://coveralls.io/r/fengmk2/utility)
22
=======
33

44
![logo](https://raw.github.com/fengmk2/utility/master/logo.png)
55

66
A collection of useful utilities.
77

8-
* jscoverage: [100%](http://fengmk2.github.com/coverage/utility.html)
9-
108
## Install
119

1210
```bash

package.json

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,20 @@
44
"description": "A collection of useful utilities.",
55
"main": "index.js",
66
"scripts": {
7-
"test": "make test"
7+
"test": "make test-all",
8+
"blanket": { "pattern": "utility/lib" },
9+
"travis-cov": { "threshold": 98 }
810
},
911
"dependencies": {
1012

1113
},
1214
"devDependencies": {
1315
"should": "*",
1416
"moment": "*",
15-
"jscover": "*",
17+
"blanket": "*",
18+
"travis-cov": "*",
19+
"coveralls": "*",
20+
"mocha-lcov-reporter": "*",
1621
"benchmark": "*",
1722
"mocha": "*"
1823
},

test/utility.test.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,13 +96,14 @@ Encode string s using a URL-safe alphabet, which substitutes - instead of + and
9696
describe('logDate()', function () {
9797
it('should return an log format date string', function () {
9898
utils.logDate().should.match(/^\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}$/);
99+
utils.logDate(new Date(1372062988014)).should.match(/^\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}$/);
99100
for (var m = 1; m <= 12; m++) {
100101
for (var d = 1; d <= 28; d++) {
101102
for (var h = 0; h < 24; h++) {
102103
var ss = parseInt(Math.random() * 60, 10);
103104
var ds = '2013-' + m + '-' + d + ' ' + h + ':' + ss + ':' + ss;
104-
var n = new Date();
105-
utils.logDate().should.match(/^\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}$/);
105+
var n = new Date(ds);
106+
utils.logDate(n).should.match(/^\d{4}\-\d{2}\-\d{2} \d{2}:\d{2}:\d{2}\.\d{3}$/);
106107
}
107108
}
108109
}
@@ -145,6 +146,10 @@ Encode string s using a URL-safe alphabet, which substitutes - instead of + and
145146
}
146147
});
147148
});
149+
150+
it('should return source string when decode error', function () {
151+
utils.decodeURIComponent('%').should.equal('%');
152+
});
148153
});
149154

150155
describe('datestruct()', function () {

0 commit comments

Comments
 (0)