diff --git a/test/peer-discovery.node.js b/test/peer-discovery.node.js index daf48c79..05298de0 100644 --- a/test/peer-discovery.node.js +++ b/test/peer-discovery.node.js @@ -59,8 +59,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), @@ -80,6 +80,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(),