mirror of
https://github.com/fluencelabs/js-libp2p
synced 2025-03-16 15:40:49 +00:00
test: add test for default registration of function module
License: MIT Signed-off-by: Alan Shaw <alan@tableflip.io>
This commit is contained in:
parent
9521e79061
commit
27c6587747
@ -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(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user