Skip to content

Commit

Permalink
Update: Add test suite
Browse files Browse the repository at this point in the history
  • Loading branch information
phated committed Oct 2, 2017
1 parent b4dd603 commit adc68b7
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 2 deletions.
5 changes: 3 additions & 2 deletions package.json
Expand Up @@ -4,7 +4,7 @@
"description": "undertaker-registry ===================",
"main": "index.js",
"scripts": {
"test": "lab -c"
"test": "lab -cv"
},
"repository": {
"type": "git",
Expand All @@ -23,6 +23,7 @@
},
"homepage": "https://github.com/phated/undertaker-registry",
"devDependencies": {
"lab": "^4.1.0"
"code": "^1.2.1",
"lab": "^5.2.0"
}
}
64 changes: 64 additions & 0 deletions test/index.js
@@ -0,0 +1,64 @@
'use strict';

var lab = exports.lab = require('lab').script();
var expect = require('code').expect;

var describe = lab.describe;
var it = lab.it;

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

function noop(){}

describe('undertaker-registry', function(){

describe('constructor', function(){

it('can be constructed with new', function(done){
var reg = new Registry();
expect(reg.get).to.be.a.function();
expect(reg.set).to.be.a.function();
expect(reg.tasks).to.be.a.function();
done();
});

it('can be constructed without new', function(done){
var reg = Registry();
expect(reg.get).to.be.a.function();
expect(reg.set).to.be.a.function();
expect(reg.tasks).to.be.a.function();
done();
});
});

describe('get', function(){

it('returns a task from the registry', function(done){
var reg = new Registry();
reg._tasks.test = noop;
expect(reg.get('test')).to.equal(noop);
done();
});
});

describe('set', function(){

it('registers a task', function(done){
var reg = new Registry();
reg.set('test', noop);
expect(reg._tasks.test).to.equal(noop);
done();
});
});

describe('tasks', function(){

it('returns an object of task name->functions', function(done){
var reg = new Registry();
reg.set('test1', noop);
reg.set('test2', noop);
expect(reg.tasks()).to.deep.equal({ test1: noop, test2: noop });
done();
});
});
});

0 comments on commit adc68b7

Please sign in to comment.