mirror of
https://github.com/hack-chat/main.git
synced 2024-03-22 13:20:33 +08:00
unit test update
Back to 100% coverage
This commit is contained in:
parent
3eafe9d766
commit
961a030a72
18
package-lock.json
generated
18
package-lock.json
generated
|
@ -1,18 +1,18 @@
|
|||
{
|
||||
"name": "hack.chat-v2",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "hack.chat-v2",
|
||||
"version": "2.2.0",
|
||||
"version": "2.2.1",
|
||||
"hasInstallScript": true,
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ascii-captcha": "^0.0.3",
|
||||
"enquirer": "^2.3.6",
|
||||
"hackchat-server": "^2.2.27",
|
||||
"hackchat-server": "^2.3.1",
|
||||
"http-server": "^14.1.0",
|
||||
"jsonwebtoken": "^9.0.2",
|
||||
"lowdb": "^3.0.0",
|
||||
|
@ -2750,9 +2750,9 @@
|
|||
}
|
||||
},
|
||||
"node_modules/hackchat-server": {
|
||||
"version": "2.2.27",
|
||||
"resolved": "https://registry.npmjs.org/hackchat-server/-/hackchat-server-2.2.27.tgz",
|
||||
"integrity": "sha512-ojTngxzBO9OYj12510XsoUEddMYbE3qf7AsRkyBfNStyiNKIMWG8/kyZkLsr/f/CIYKJZCQ3/Es6Cu6t/FBHvA==",
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/hackchat-server/-/hackchat-server-2.3.1.tgz",
|
||||
"integrity": "sha512-q287JzAP3shM1pBq6ZG9BUza0bCuunz4R9hV5jgBEwAvJtp+t8P4ZNL8XpSnGe7Rcc9pkhg26uHMZ7TtUL5MYQ==",
|
||||
"dependencies": {
|
||||
"didyoumean2": "^4.2.0",
|
||||
"enquirer": "^2.3.6",
|
||||
|
@ -8081,9 +8081,9 @@
|
|||
"dev": true
|
||||
},
|
||||
"hackchat-server": {
|
||||
"version": "2.2.27",
|
||||
"resolved": "https://registry.npmjs.org/hackchat-server/-/hackchat-server-2.2.27.tgz",
|
||||
"integrity": "sha512-ojTngxzBO9OYj12510XsoUEddMYbE3qf7AsRkyBfNStyiNKIMWG8/kyZkLsr/f/CIYKJZCQ3/Es6Cu6t/FBHvA==",
|
||||
"version": "2.3.1",
|
||||
"resolved": "https://registry.npmjs.org/hackchat-server/-/hackchat-server-2.3.1.tgz",
|
||||
"integrity": "sha512-q287JzAP3shM1pBq6ZG9BUza0bCuunz4R9hV5jgBEwAvJtp+t8P4ZNL8XpSnGe7Rcc9pkhg26uHMZ7TtUL5MYQ==",
|
||||
"requires": {
|
||||
"didyoumean2": "^4.2.0",
|
||||
"enquirer": "^2.3.6",
|
||||
|
|
|
@ -38,8 +38,10 @@ describe('Checking addmod module', () => {
|
|||
|
||||
// module main function
|
||||
it('should be invokable only by an admin', async () => {
|
||||
const newCore = Object.assign({}, mocks.core);
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
core: newCore,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: mockPayload,
|
||||
|
@ -49,8 +51,10 @@ describe('Checking addmod module', () => {
|
|||
});
|
||||
|
||||
it('should add new trip to the config', async () => {
|
||||
const newCore = Object.assign({}, mocks.core);
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
core: newCore,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
|
@ -60,18 +64,17 @@ describe('Checking addmod module', () => {
|
|||
});
|
||||
|
||||
it('should inform the new mod', async () => {
|
||||
const newCore = Object.assign({}, mocks.core);
|
||||
mocks.server.findSockets = () => {
|
||||
return [{}];
|
||||
}
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
core: newCore,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
});
|
||||
|
||||
mocks.core.appConfig.data.globalMods = [];
|
||||
|
||||
expect(resp).to.be.true;
|
||||
});
|
||||
|
|
|
@ -181,6 +181,32 @@ describe('Checking join module', () => {
|
|||
expect(resp).to.be.true;
|
||||
});
|
||||
|
||||
it('should provide mod perks', async () => {
|
||||
const newCore = Object.assign({}, mocks.core);
|
||||
newCore.appConfig.data.globalMods = [
|
||||
{
|
||||
trip: 'XVeP3T',
|
||||
}
|
||||
];
|
||||
|
||||
const newSocket = Object.assign({}, mocks.authedSocket);
|
||||
newSocket.channel = undefined;
|
||||
newSocket.hcProtocol = undefined;
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: newCore,
|
||||
server: mocks.server,
|
||||
socket: newSocket,
|
||||
payload: {
|
||||
cmd: 'join',
|
||||
nick: 'admin#test',
|
||||
channel: 'cake',
|
||||
},
|
||||
});
|
||||
|
||||
expect(newSocket.ratelimitImmune).to.be.true;
|
||||
});
|
||||
|
||||
it('should announce new user', async () => {
|
||||
const newSocket = Object.assign({}, mocks.authedSocket);
|
||||
newSocket.channel = undefined;
|
||||
|
|
|
@ -6,7 +6,7 @@ let importedModule;
|
|||
|
||||
const mockPayload = {
|
||||
cmd: 'removemod',
|
||||
trip: 'newTrip',
|
||||
trip: 'XVeP3T',
|
||||
}
|
||||
|
||||
describe('Checking removemod module', () => {
|
||||
|
@ -38,8 +38,10 @@ describe('Checking removemod module', () => {
|
|||
|
||||
// module main function
|
||||
it('should be invokable only by an admin', async () => {
|
||||
const newCore = Object.assign({}, mocks.core);
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
core: newCore,
|
||||
server: mocks.server,
|
||||
socket: mocks.plebSocket,
|
||||
payload: mockPayload,
|
||||
|
@ -49,8 +51,10 @@ describe('Checking removemod module', () => {
|
|||
});
|
||||
|
||||
it('should remove trip from the config', async () => {
|
||||
const newCore = Object.assign({}, mocks.core);
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
core: newCore,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
|
@ -60,12 +64,14 @@ describe('Checking removemod module', () => {
|
|||
});
|
||||
|
||||
it('should inform the ex-mod', async () => {
|
||||
const newCore = Object.assign({}, mocks.core);
|
||||
|
||||
mocks.server.findSockets = () => {
|
||||
return [{}];
|
||||
}
|
||||
|
||||
const resp = await importedModule.run({
|
||||
core: mocks.core,
|
||||
core: newCore,
|
||||
server: mocks.server,
|
||||
socket: mocks.authedSocket,
|
||||
payload: mockPayload,
|
||||
|
|
Loading…
Reference in New Issue
Block a user