Skip to content

Commit

Permalink
tweak testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
xudafeng committed Oct 29, 2016
1 parent 6845685 commit 0578e6f
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 17 deletions.
18 changes: 11 additions & 7 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,24 @@ npm_bin= $$(npm bin)
all: test
install:
@npm install
server:
npm i startserver --save-dev
${npm_bin}/startserver -s -p 8080 &
pre-test: server
sleep 5
test:
@node --harmony \
@node \
${npm_bin}/istanbul cover ${npm_bin}/_mocha \
-- \
--timeout 10000 \
--require co-mocha
travis: install
@NODE_ENV=test $(BIN) $(FLAGS) \
./node_modules/.bin/istanbul cover \
./node_modules/.bin/_mocha \
travis: install pre-test
@node \
${npm_bin}/istanbul cover ${npm_bin}/_mocha \
--report lcovonly \
-- -u exports \
$(REQUIRED) \
$(TESTS) \
--timeout 10000 \
--require co-mocha \
--bail
jshint:
@${npm_bin}/jshint .
Expand Down
29 changes: 19 additions & 10 deletions test/detect-port.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,34 +40,43 @@ describe('detect port test', () => {
it('generator usage', function *() {
var _port = 8080;
try {
var port = yield detectPort(8080);
var port = yield detectPort(_port);
port.should.within(_port, 65535);
} catch (err) {
console.log(err);
}
});

it('promise usage', function *() {
detectPort(8080)
it('promise usage', done => {
var _port = 8080;
detectPort(_port)
.then(port => {
console.log(port);
port.should.within(_port, 65535);
done();
})
.catch(err => {
console.log(err);
done();
});
});

it('generator with wrong arguments', function *() {
try {
yield detectPort();
} catch (err) {
err.should.containEql('wrong number of arguments');
}
it('promise with wrong arguments', done => {
detectPort()
.then(() => {
done();
})
.catch(err => {
err.should.containEql('wrong number of arguments');
done();
});
});

it('generator with wrong arguments', function *() {
try {
yield detectPort('8080');
} catch (err) {
err.should.containEql('wrong type of arguments');
}
});

});

0 comments on commit 0578e6f

Please sign in to comment.