Skip to content

Commit

Permalink
use mock-git to increase coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
stevemao committed Jun 2, 2016
1 parent 26868b7 commit d97be6a
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
/node_modules/
/coverage/
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -33,10 +33,11 @@
"istanbul": "^0.3.17",
"jscs": "^2.0.0",
"jshint": "^2.8.0",
"mocha": "*"
"mocha": "*",
"mock-git": "^1.0.2"
},
"scripts": {
"coverage": "istanbul cover _mocha -- -R spec && rm -rf ./coverage",
"coverage": "istanbul cover _mocha -- -R spec",
"lint": "jshint *.js test --exclude node_modules && jscs *.js test",
"test": "npm run-script lint && mocha"
},
Expand Down
15 changes: 15 additions & 0 deletions test/test.js
@@ -1,12 +1,27 @@
'use strict';
var assert = require('assert');
var gitTails = require('../');
var mockGit = require('mock-git');
var unmock;

it('should throw if no callback', function() {
assert.throws(gitTails);
});

it('should callback with error', function(done) {
mockGit('throw new Error("Suck it")', 'rev-list')
.then(function(_unmock_) {
unmock = _unmock_;

gitTails(function(err) {
assert.ok(err);
done();
});
});
});

it('should get the first commit', function(done) {
unmock();
gitTails(function(err, data) {
assert.deepEqual(data, ['9594829e694c5284ab6ef3816ded02ca104fee59']);
done();
Expand Down

0 comments on commit d97be6a

Please sign in to comment.