Skip to content

Commit

Permalink
test: add test for default registration of function module
Browse files Browse the repository at this point in the history
License: MIT
Signed-off-by: Alan Shaw <alan@tableflip.io>
  • Loading branch information
alanshaw committed Jun 28, 2018
1 parent 50e1d8d commit 2371c09
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions test/peer-discovery.node.js
Expand Up @@ -58,8 +58,8 @@ describe('peer discovery', () => {
})
}

describe('module registration', () => {
it('should enable module by default', (done) => {
describe.only('module registration', () => {
it('should enable by default a module passed as an object', (done) => {
const mockDiscovery = {
on: sinon.stub(),
start: sinon.stub().callsArg(0),
Expand All @@ -79,6 +79,28 @@ describe('peer discovery', () => {
})
})

it('should enable by default a module passed as a function', (done) => {
const mockDiscovery = {
on: sinon.stub(),
start: sinon.stub().callsArg(0),
stop: sinon.stub().callsArg(0)
}

const MockDiscovery = sinon.stub().returns(mockDiscovery)

const options = { modules: { peerDiscovery: [ MockDiscovery ] } }

createNode(['/ip4/0.0.0.0/tcp/0'], options, (err, node) => {
expect(err).to.not.exist()

node.start((err) => {
expect(err).to.not.exist()
expect(mockDiscovery.start.called).to.be.true()
node.stop(done)
})
})
})

it('should enable module by configutation', (done) => {
const mockDiscovery = {
on: sinon.stub(),
Expand Down

0 comments on commit 2371c09

Please sign in to comment.