UNPKG

libp2p-pubsub

Version:
50 lines 1.64 kB
import { expect } from 'aegir/utils/chai.js'; import { PubsubBaseProtocol } from '../src/index.js'; import { createPeerId, mockRegistrar } from './utils/index.js'; class PubsubProtocol extends PubsubBaseProtocol { async _publish(message) { throw new Error('Method not implemented.'); } } describe('pubsub instance', () => { let peerId; before(async () => { peerId = await createPeerId(); }); it('should throw if no debugName is provided', () => { expect(() => { // @ts-expect-error incorrect constructor args new PubsubProtocol(); // eslint-disable-line no-new }).to.throw(); }); it('should throw if no multicodec is provided', () => { expect(() => { // @ts-expect-error incorrect constructor args new PubsubProtocol({ debugName: 'pubsub' }); }).to.throw(); }); it('should throw if no libp2p is provided', () => { expect(() => { // @ts-expect-error incorrect constructor args new PubsubProtocol({ debugName: 'pubsub', multicodecs: ['/pubsub/1.0.0'] }); }).to.throw(); }); it('should accept valid parameters', () => { expect(() => { new PubsubProtocol({ debugName: 'pubsub', multicodecs: ['/pubsub/1.0.0'], libp2p: { peerId: peerId, registrar: mockRegistrar } }); }).not.to.throw(); }); }); //# sourceMappingURL=instance.spec.js.map