add tests for errors

master
jonschlinkert 10 years ago
parent 7812606e64
commit d2382fee74

@ -8,32 +8,44 @@
'use strict'; 'use strict';
var should = require('should'); var should = require('should');
var config = require('./'); var git = require('./');
describe('sync:', function () { describe('sync:', function () {
it('should return an object', function () { it('should return an object', function () {
config.sync().should.have.properties([]); git.sync().should.have.properties(['core']);
git.sync().should.not.have.properties(['foo']);
git.sync().should.not.throw;
}); });
it('should throw an error when .git/config does not exist:', function () { it('should throw an error when .git/config does not exist:', function () {
(function () { (function () {
config.sync('foo'); git.sync('foo');
}).should.throw('.git/config does not exist.'); }).should.throw('.git/config does not exist.');
}); });
}); });
describe('async:', function () { describe('async:', function () {
it('should throw a callback is not passed:', function (cb) {
(function () {
git();
}).should.throw('parse-git-config async expects a callback function.')
cb();
});
it('should throw an error when .git/config does not exist:', function (cb) { it('should throw an error when .git/config does not exist:', function (cb) {
config(function (err, data) { git(function (err, config) {
console.log(arguments) config.should.have.property('core');
config.should.not.have.property('foo');
cb();
}); });
cb();
}); });
it('should throw an error when .git/config does not exist:', function (cb) { it('should throw an error when .git/config does not exist:', function (cb) {
config('foo', function (err, data) { git('foo', function (err, config) {
console.log(arguments) err.should.be.an.instanceof(Error);
err.message.should.equal('ENOENT, open \'foo/.git/config\'');
cb();
}); });
cb();
}); });
}); });

Loading…
Cancel
Save