Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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(); | ||
}); | ||
}); | ||
}); |