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",
|
"name": "hack.chat-v2",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"lockfileVersion": 2,
|
"lockfileVersion": 2,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "hack.chat-v2",
|
"name": "hack.chat-v2",
|
||||||
"version": "2.2.0",
|
"version": "2.2.1",
|
||||||
"hasInstallScript": true,
|
"hasInstallScript": true,
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"ascii-captcha": "^0.0.3",
|
"ascii-captcha": "^0.0.3",
|
||||||
"enquirer": "^2.3.6",
|
"enquirer": "^2.3.6",
|
||||||
"hackchat-server": "^2.2.27",
|
"hackchat-server": "^2.3.1",
|
||||||
"http-server": "^14.1.0",
|
"http-server": "^14.1.0",
|
||||||
"jsonwebtoken": "^9.0.2",
|
"jsonwebtoken": "^9.0.2",
|
||||||
"lowdb": "^3.0.0",
|
"lowdb": "^3.0.0",
|
||||||
|
@ -2750,9 +2750,9 @@
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/hackchat-server": {
|
"node_modules/hackchat-server": {
|
||||||
"version": "2.2.27",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/hackchat-server/-/hackchat-server-2.2.27.tgz",
|
"resolved": "https://registry.npmjs.org/hackchat-server/-/hackchat-server-2.3.1.tgz",
|
||||||
"integrity": "sha512-ojTngxzBO9OYj12510XsoUEddMYbE3qf7AsRkyBfNStyiNKIMWG8/kyZkLsr/f/CIYKJZCQ3/Es6Cu6t/FBHvA==",
|
"integrity": "sha512-q287JzAP3shM1pBq6ZG9BUza0bCuunz4R9hV5jgBEwAvJtp+t8P4ZNL8XpSnGe7Rcc9pkhg26uHMZ7TtUL5MYQ==",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"didyoumean2": "^4.2.0",
|
"didyoumean2": "^4.2.0",
|
||||||
"enquirer": "^2.3.6",
|
"enquirer": "^2.3.6",
|
||||||
|
@ -8081,9 +8081,9 @@
|
||||||
"dev": true
|
"dev": true
|
||||||
},
|
},
|
||||||
"hackchat-server": {
|
"hackchat-server": {
|
||||||
"version": "2.2.27",
|
"version": "2.3.1",
|
||||||
"resolved": "https://registry.npmjs.org/hackchat-server/-/hackchat-server-2.2.27.tgz",
|
"resolved": "https://registry.npmjs.org/hackchat-server/-/hackchat-server-2.3.1.tgz",
|
||||||
"integrity": "sha512-ojTngxzBO9OYj12510XsoUEddMYbE3qf7AsRkyBfNStyiNKIMWG8/kyZkLsr/f/CIYKJZCQ3/Es6Cu6t/FBHvA==",
|
"integrity": "sha512-q287JzAP3shM1pBq6ZG9BUza0bCuunz4R9hV5jgBEwAvJtp+t8P4ZNL8XpSnGe7Rcc9pkhg26uHMZ7TtUL5MYQ==",
|
||||||
"requires": {
|
"requires": {
|
||||||
"didyoumean2": "^4.2.0",
|
"didyoumean2": "^4.2.0",
|
||||||
"enquirer": "^2.3.6",
|
"enquirer": "^2.3.6",
|
||||||
|
|
|
@ -38,8 +38,10 @@ describe('Checking addmod module', () => {
|
||||||
|
|
||||||
// module main function
|
// module main function
|
||||||
it('should be invokable only by an admin', async () => {
|
it('should be invokable only by an admin', async () => {
|
||||||
|
const newCore = Object.assign({}, mocks.core);
|
||||||
|
|
||||||
const resp = await importedModule.run({
|
const resp = await importedModule.run({
|
||||||
core: mocks.core,
|
core: newCore,
|
||||||
server: mocks.server,
|
server: mocks.server,
|
||||||
socket: mocks.plebSocket,
|
socket: mocks.plebSocket,
|
||||||
payload: mockPayload,
|
payload: mockPayload,
|
||||||
|
@ -49,8 +51,10 @@ describe('Checking addmod module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should add new trip to the config', async () => {
|
it('should add new trip to the config', async () => {
|
||||||
|
const newCore = Object.assign({}, mocks.core);
|
||||||
|
|
||||||
const resp = await importedModule.run({
|
const resp = await importedModule.run({
|
||||||
core: mocks.core,
|
core: newCore,
|
||||||
server: mocks.server,
|
server: mocks.server,
|
||||||
socket: mocks.authedSocket,
|
socket: mocks.authedSocket,
|
||||||
payload: mockPayload,
|
payload: mockPayload,
|
||||||
|
@ -60,19 +64,18 @@ describe('Checking addmod module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should inform the new mod', async () => {
|
it('should inform the new mod', async () => {
|
||||||
|
const newCore = Object.assign({}, mocks.core);
|
||||||
mocks.server.findSockets = () => {
|
mocks.server.findSockets = () => {
|
||||||
return [{}];
|
return [{}];
|
||||||
}
|
}
|
||||||
|
|
||||||
const resp = await importedModule.run({
|
const resp = await importedModule.run({
|
||||||
core: mocks.core,
|
core: newCore,
|
||||||
server: mocks.server,
|
server: mocks.server,
|
||||||
socket: mocks.authedSocket,
|
socket: mocks.authedSocket,
|
||||||
payload: mockPayload,
|
payload: mockPayload,
|
||||||
});
|
});
|
||||||
|
|
||||||
mocks.core.appConfig.data.globalMods = [];
|
|
||||||
|
|
||||||
expect(resp).to.be.true;
|
expect(resp).to.be.true;
|
||||||
});
|
});
|
||||||
});
|
});
|
|
@ -181,6 +181,32 @@ describe('Checking join module', () => {
|
||||||
expect(resp).to.be.true;
|
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 () => {
|
it('should announce new user', async () => {
|
||||||
const newSocket = Object.assign({}, mocks.authedSocket);
|
const newSocket = Object.assign({}, mocks.authedSocket);
|
||||||
newSocket.channel = undefined;
|
newSocket.channel = undefined;
|
||||||
|
|
|
@ -6,7 +6,7 @@ let importedModule;
|
||||||
|
|
||||||
const mockPayload = {
|
const mockPayload = {
|
||||||
cmd: 'removemod',
|
cmd: 'removemod',
|
||||||
trip: 'newTrip',
|
trip: 'XVeP3T',
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('Checking removemod module', () => {
|
describe('Checking removemod module', () => {
|
||||||
|
@ -38,8 +38,10 @@ describe('Checking removemod module', () => {
|
||||||
|
|
||||||
// module main function
|
// module main function
|
||||||
it('should be invokable only by an admin', async () => {
|
it('should be invokable only by an admin', async () => {
|
||||||
|
const newCore = Object.assign({}, mocks.core);
|
||||||
|
|
||||||
const resp = await importedModule.run({
|
const resp = await importedModule.run({
|
||||||
core: mocks.core,
|
core: newCore,
|
||||||
server: mocks.server,
|
server: mocks.server,
|
||||||
socket: mocks.plebSocket,
|
socket: mocks.plebSocket,
|
||||||
payload: mockPayload,
|
payload: mockPayload,
|
||||||
|
@ -49,8 +51,10 @@ describe('Checking removemod module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should remove trip from the config', async () => {
|
it('should remove trip from the config', async () => {
|
||||||
|
const newCore = Object.assign({}, mocks.core);
|
||||||
|
|
||||||
const resp = await importedModule.run({
|
const resp = await importedModule.run({
|
||||||
core: mocks.core,
|
core: newCore,
|
||||||
server: mocks.server,
|
server: mocks.server,
|
||||||
socket: mocks.authedSocket,
|
socket: mocks.authedSocket,
|
||||||
payload: mockPayload,
|
payload: mockPayload,
|
||||||
|
@ -60,12 +64,14 @@ describe('Checking removemod module', () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should inform the ex-mod', async () => {
|
it('should inform the ex-mod', async () => {
|
||||||
|
const newCore = Object.assign({}, mocks.core);
|
||||||
|
|
||||||
mocks.server.findSockets = () => {
|
mocks.server.findSockets = () => {
|
||||||
return [{}];
|
return [{}];
|
||||||
}
|
}
|
||||||
|
|
||||||
const resp = await importedModule.run({
|
const resp = await importedModule.run({
|
||||||
core: mocks.core,
|
core: newCore,
|
||||||
server: mocks.server,
|
server: mocks.server,
|
||||||
socket: mocks.authedSocket,
|
socket: mocks.authedSocket,
|
||||||
payload: mockPayload,
|
payload: mockPayload,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user