1
0
mirror of https://github.com/hack-chat/main.git synced 2024-03-22 13:20:33 +08:00
hack-chat-main/test/legacyFunctions.test.js
2022-06-22 11:32:51 -05:00

52 lines
1.5 KiB
JavaScript

import { expect } from 'chai';
import mocks from './mockImports.js';
const modulePath = '../commands/utility/_LegacyFunctions.js';
let importedModule;
describe('Checking legacyFunctions module', () => {
it('should be importable', async () => {
importedModule = await import(modulePath);
expect(importedModule).to.not.be.a('string');
});
it('should handle pass and password', async () => {
const resp = importedModule.upgradeLegacyJoin(mocks.server, mocks.plebSocket, {
nick: 'test#test',
password: 'test',
});
expect(resp).to.be.an('object');
});
it('should handle mod label', async () => {
const resp = importedModule.legacyLevelToLabel(9999999);
expect(resp).to.equal('admin');
});
it('should handle mod label', async () => {
const resp = importedModule.legacyLevelToLabel(999999);
expect(resp).to.equal('mod');
});
it('should provide duplicate user checks', async () => {
const newSocket = Object.assign({}, mocks.plebSocket);
newSocket.trip = false;
const resp = importedModule.legacyWhisperOut({
cmd: 'whisper',
}, newSocket);
expect(resp).to.be.an('object');
});
it('should apply missing user id', async () => {
const newSocket = Object.assign({}, mocks.authedSocket);
newSocket.userid = undefined;
const resp = importedModule.upgradeLegacyJoin(mocks.server, newSocket, {
nick: 'test#test',
password: 'test',
});
expect(resp).to.be.an('object');
});
})