import { expect } from 'chai'; import mocks from './mockImports.js'; const modulePath = '../commands/internal/socketreply.js'; let importedModule; const mockPayload = { cmd: 'disconnect', } describe('Checking socketreply module', () => { // module meta data it('should be importable', async () => { importedModule = await import(modulePath); expect(importedModule).to.not.be.a('string'); }); it('should be named', async () => { expect(importedModule.info.name).to.be.a('string'); }); it('should be categorized', async () => { expect(importedModule.info.category).to.be.a('string'); }); it('should be described', async () => { expect(importedModule.info.description).to.be.a('string'); }); it('should be documented', async () => { expect(importedModule.info.usage).to.be.a('string'); }); it('should be invokable', async () => { expect(importedModule.run).to.be.a('function'); }); // module main function it('should be invokable only internally', async () => { const resp = await importedModule.run({ core: mocks.core, server: mocks.server, socket: mocks.plebSocket, payload: mockPayload, }); expect(resp).to.be.false; }); it('should broadcast warning event', async () => { mockPayload.cmdKey = 'test'; const resp = await importedModule.run({ core: mocks.core, server: mocks.server, socket: mocks.plebSocket, payload: mockPayload, }); expect(resp).to.be.true; }); });