Skip to content

Commit

Permalink
update testcase
Browse files Browse the repository at this point in the history
  • Loading branch information
xudafeng committed Sep 25, 2016
1 parent 056e43e commit 2c700e0
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 6 deletions.
24 changes: 19 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,21 +28,35 @@ $ npm i command-line-test --save-dev
## Usage

```javascript
const CliTest = require('..');

const pkg = require('../package');

describe('test', function() {
it('constructor should be ok', function() {
CliTest.should.be.ok();
});

it('exec method should be ok', function *() {
it('exec method should be ok with yeild', function *() {
const cliTest = new CliTest();
const res = yield cliTest.exec('cat package.json');
const _pkg = JSON.parse(res.stdout);
pkg.name.should.be.equal(_pkg.name);
});

it('exec method should be ok with promise', function(done) {
const cliTest1 = new CliTest();
cliTest1.exec('cat package.json').then(res => {
const _pkg = JSON.parse(res.stdout);
pkg.name.should.be.equal(_pkg.name);
done();
});
});

it('exec method should be ok with callback', function(done) {
const cliTest1 = new CliTest();
cliTest1.exec('cat package.json', function(err, res) {
const _pkg = JSON.parse(res.stdout);
pkg.name.should.be.equal(_pkg.name);
done();
});
});
});
```

Expand Down
20 changes: 19 additions & 1 deletion test/command-line-test.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,28 @@ describe('test', function() {
CliTest.should.be.ok();
});

it('exec method should be ok', function *() {
it('exec method should be ok with yeild', function *() {
const cliTest = new CliTest();
const res = yield cliTest.exec('cat package.json');
const _pkg = JSON.parse(res.stdout);
pkg.name.should.be.equal(_pkg.name);
});

it('exec method should be ok with promise', function(done) {
const cliTest1 = new CliTest();
cliTest1.exec('cat package.json').then(res => {
const _pkg = JSON.parse(res.stdout);
pkg.name.should.be.equal(_pkg.name);
done();
});
});

it('exec method should be ok with callback', function(done) {
const cliTest1 = new CliTest();
cliTest1.exec('cat package.json', function(err, res) {
const _pkg = JSON.parse(res.stdout);
pkg.name.should.be.equal(_pkg.name);
done();
});
});
});

0 comments on commit 2c700e0

Please sign in to comment.