Skip to content

Commit

Permalink
Update: Switch to lab for testing & coverage (closes #1, closes #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Jun 25, 2016
1 parent 93f9f88 commit 6389bc4
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 33 deletions.
18 changes: 7 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,13 @@
"test": "test"
},
"scripts": {
"test": "tap ./test"
"test": "lab -cv"
},
"repository": {
"type": "git",
"url": "git://github.com/phated/async-settle"
"dependencies": {
"async-done": "^0.4.0"
},
"devDependencies": {
"lab": "^4.2.0"
},
"keywords": [
"settle",
Expand All @@ -26,11 +28,5 @@
"bugs": {
"url": "https://github.com/phated/async-settle/issues"
},
"homepage": "https://github.com/phated/async-settle",
"devDependencies": {
"tap": "^0.4.8"
},
"dependencies": {
"async-done": "^0.4.0"
}
"homepage": "https://github.com/phated/async-settle"
}
50 changes: 28 additions & 22 deletions test/index.js
Original file line number Diff line number Diff line change
@@ -1,31 +1,37 @@
'use strict';

var test = require('tap').test;
var lab = exports.lab = require('lab').script();
var describe = lab.describe;
var it = lab.it;
var before = lab.before;
var beforeEach = lab.beforeEach;
var after = lab.after;
var afterEach = lab.afterEach;
var expect = require('lab').expect;

var settle = require('../');

test('should transform success into settled success values', function(t){
var val = 'value to be settled';
settle(function(done){
done(null, val);
}, function(error, result){
t.notOk(error, 'error should be undefined');
t.ok(result, 'result should be defined');
t.ok(result.state === 'success', 'state should be "success"');
t.equal(result.value, val, 'value should be the success value');
t.end();
describe('asyncSettle', function(){

it('should transform success into settled success values', function(done){
var val = 'value to be settled';
settle(function(done){
done(null, val);
}, function(err, result){
expect(result).to.have.property('state', 'success');
expect(result).to.have.property('value', val);
done(err);
});
});
});

test('should transform errors into settled success values', function(t){
var err = new Error('Error to be settled');
settle(function(done){
done(err);
}, function(error, result){
t.notOk(error, 'error should be undefined');
t.ok(result, 'result should be defined');
t.ok(result.state === 'error', 'state should be "error"');
t.equal(result.value, err, 'value should be the error value');
t.end();
it('should transform errors into settled success values', function(done){
var error = new Error('Error to be settled');
settle(function(done){
done(error);
}, function(err, result){
expect(result).to.have.property('state', 'error');
expect(result).to.have.property('value', error);
done(err);
});
});
});

0 comments on commit 6389bc4

Please # to comment.