修复test.ts的引用

This commit is contained in:
luying
2022-04-09 11:04:28 +08:00
parent 12d47ec881
commit a23759335e
3 changed files with 27 additions and 27 deletions
+2 -2
View File
@@ -1,7 +1,7 @@
import { PinusWSClient } from 'pinus-robot-plugin'; import { PinusWSClient } from 'pinus-robot-plugin';
import { expect } from 'chai'; import { expect } from 'chai';
import { checkSuccessResponse, checkRoleInfo } from './CheckPatten'; import { checkSuccessResponse, checkRoleInfo } from './CheckPatten';
import { DEBUG_MAGIC_WORD, ON_ADD_CHANNEL_ROUTE, STATUS } from '../app/consts'; import { DEBUG_MAGIC_WORD, PUSH_ROUTE, STATUS } from '../app/consts';
import { genCode } from '../app/pubUtils/util'; import { genCode } from '../app/pubUtils/util';
const request = require('request'); const request = require('request');
const crypto = require('crypto'); const crypto = require('crypto');
@@ -61,7 +61,7 @@ export class Client {
port: port port: port
}, (data) => { }, (data) => {
// 连接成功执行函数 // 连接成功执行函数
this._client.on(ON_ADD_CHANNEL_ROUTE, (msg) => { this._client.on(PUSH_ROUTE.ADD_CHANNEL, (msg) => {
checkSuccessResponse(msg); checkSuccessResponse(msg);
expect(msg.data.roleId).to.be.a('string'); expect(msg.data.roleId).to.be.a('string');
expect(msg.data.channelName).to.be.a('string'); expect(msg.data.channelName).to.be.a('string');
+21 -21
View File
@@ -1,11 +1,11 @@
import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, ON_PRIVATE_MSG_ROUTE, ON_GROUP_MSG_ROUTE, CHANNEL_PREFIX, DEBUG_MAGIC_WORD, STATUS, HERO_GROW_MAX, ABI_STAGE } from './../app/consts'; import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, PUSH_ROUTE, CHANNEL_PREFIX, DEBUG_MAGIC_WORD, STATUS, HERO_GROW_MAX, ABI_STAGE } from './../app/consts';
import { Client } from './Client'; import { Client } from './Client';
import 'mocha'; import 'mocha';
import { PinusWSClient } from 'pinus-robot-plugin'; import { PinusWSClient } from 'pinus-robot-plugin';
import { expect } from 'chai'; import { expect } from 'chai';
import { checkSuccessResponse } from './CheckPatten'; import { checkSuccessResponse } from './CheckPatten';
const TEXT_MSG = { type: MSG_TYPE.TEXT, content: 'hello world' } const TEXT_MSG = { type: MSG_TYPE.TEXT, content: 'hello' }
const LVBU_HID = 44; const LVBU_HID = 44;
const XIAHOUQINGYI_HID = 53; const XIAHOUQINGYI_HID = 53;
@@ -42,12 +42,12 @@ function checkHeroInfoStr(content: string) {
function testGroupMsg(pinusClient: PinusWSClient, roleInfo: any, pinusClientT: PinusWSClient, channel: string, channelId: string, done: Mocha.Done) { function testGroupMsg(pinusClient: PinusWSClient, roleInfo: any, pinusClientT: PinusWSClient, channel: string, channelId: string, done: Mocha.Done) {
let msgReceiveCnt = 0; let msgReceiveCnt = 0;
const roomId = `${channel}_${channelId}`; const roomId = `${channel}_${channelId}`;
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkSuccessResponse(res); checkSuccessResponse(res);
checkGroupMsg(res.data, roleInfo.roleId, roomId, TEXT_MSG.content); checkGroupMsg(res.data, roleInfo.roleId, roomId, TEXT_MSG.content);
msgReceiveCnt += 1; msgReceiveCnt += 1;
}); });
pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkSuccessResponse(res); checkSuccessResponse(res);
checkGroupMsg(res.data, roleInfo.roleId, roomId, TEXT_MSG.content); checkGroupMsg(res.data, roleInfo.roleId, roomId, TEXT_MSG.content);
msgReceiveCnt += 1; msgReceiveCnt += 1;
@@ -57,8 +57,8 @@ function testGroupMsg(pinusClient: PinusWSClient, roleInfo: any, pinusClientT: P
checkSuccessResponse(res, false); checkSuccessResponse(res, false);
setTimeout(() => { setTimeout(() => {
expect(msgReceiveCnt).to.be.equal(2); expect(msgReceiveCnt).to.be.equal(2);
pinusClientT.off(ON_GROUP_MSG_ROUTE); pinusClientT.off(PUSH_ROUTE.GROUP_MSG);
pinusClient.off(ON_GROUP_MSG_ROUTE); pinusClient.off(PUSH_ROUTE.GROUP_MSG);
done(); done();
}, 2000); }, 2000);
}); });
@@ -67,12 +67,12 @@ function testGroupMsg(pinusClient: PinusWSClient, roleInfo: any, pinusClientT: P
// function testHeroPush(pinusClient: PinusWSClient, pinusClientT: PinusWSClient, hid: number, route: string, routeParam: object, done: Mocha.Done) { // function testHeroPush(pinusClient: PinusWSClient, pinusClientT: PinusWSClient, hid: number, route: string, routeParam: object, done: Mocha.Done) {
// let msgReceiveCnt = 0; // let msgReceiveCnt = 0;
// pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { // pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => {
// checkSuccessResponse(res); // checkSuccessResponse(res);
// checkHeroInfoStr(res.data.content); // checkHeroInfoStr(res.data.content);
// msgReceiveCnt += 1; // msgReceiveCnt += 1;
// }); // });
// pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { // pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => {
// checkSuccessResponse(res); // checkSuccessResponse(res);
// checkHeroInfoStr(res.data.content); // checkHeroInfoStr(res.data.content);
// msgReceiveCnt += 1; // msgReceiveCnt += 1;
@@ -124,7 +124,7 @@ describe('聊天测试', function () {
}); });
it('两个玩家互相发送', function (done) { it('两个玩家互相发送', function (done) {
pinusClientT.on(ON_PRIVATE_MSG_ROUTE, (msg) => { pinusClientT.on(PUSH_ROUTE.PRIVATE_MSG, (msg) => {
checkSuccessResponse(msg); checkSuccessResponse(msg);
expect(msg.data.content).to.equal(TEXT_MSG.content); expect(msg.data.content).to.equal(TEXT_MSG.content);
}); });
@@ -196,12 +196,12 @@ describe('聊天测试', function () {
it('测试系统频道橙将合成消息', function (done) { it('测试系统频道橙将合成消息', function (done) {
let msgReceiveCnt = 0; let msgReceiveCnt = 0;
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkSuccessResponse(res); checkSuccessResponse(res);
// checkHeroInfoStr(res.data.content); // checkHeroInfoStr(res.data.content);
msgReceiveCnt += 1; msgReceiveCnt += 1;
}); });
pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkSuccessResponse(res); checkSuccessResponse(res);
// checkHeroInfoStr(res.data.content); // checkHeroInfoStr(res.data.content);
msgReceiveCnt += 1; msgReceiveCnt += 1;
@@ -214,8 +214,8 @@ describe('聊天测试', function () {
checkSuccessResponse(composeRes); checkSuccessResponse(composeRes);
setTimeout(() => { setTimeout(() => {
expect(msgReceiveCnt).to.be.equal(2); expect(msgReceiveCnt).to.be.equal(2);
pinusClientT.off(ON_GROUP_MSG_ROUTE); pinusClientT.off(PUSH_ROUTE.GROUP_MSG);
pinusClient.off(ON_GROUP_MSG_ROUTE); pinusClient.off(PUSH_ROUTE.GROUP_MSG);
done(); done();
}, 1000); }, 1000);
}); });
@@ -225,12 +225,12 @@ describe('聊天测试', function () {
// 材料不足先跳过 // 材料不足先跳过
it.skip('测试系统频道升六星消息', function (done) { it.skip('测试系统频道升六星消息', function (done) {
let msgReceiveCnt = 0; let msgReceiveCnt = 0;
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkSuccessResponse(res); checkSuccessResponse(res);
// checkHeroInfoStr(res.data.content); // checkHeroInfoStr(res.data.content);
msgReceiveCnt += 1; msgReceiveCnt += 1;
}); });
pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkSuccessResponse(res); checkSuccessResponse(res);
// checkHeroInfoStr(res.data.content); // checkHeroInfoStr(res.data.content);
msgReceiveCnt += 1; msgReceiveCnt += 1;
@@ -267,10 +267,10 @@ describe('聊天测试', function () {
// checkHeroInfoStr(res.data.content); // checkHeroInfoStr(res.data.content);
msgReceiveCnt += 1; msgReceiveCnt += 1;
} }
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkHeroInfoRes(res); checkHeroInfoRes(res);
}); });
pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkHeroInfoRes(res); checkHeroInfoRes(res);
}); });
pinusClient.request('role.heroHandler.testCleanUp', { magicWord: DEBUG_MAGIC_WORD, hid: XIAHOUQINGYI_HID }, (cleanUpRes) => { pinusClient.request('role.heroHandler.testCleanUp', { magicWord: DEBUG_MAGIC_WORD, hid: XIAHOUQINGYI_HID }, (cleanUpRes) => {
@@ -337,10 +337,10 @@ describe('聊天测试', function () {
expect(res.data.content).to.be.equal(newNotice); expect(res.data.content).to.be.equal(newNotice);
msgReceiveCnt += 1; msgReceiveCnt += 1;
} }
pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkNoticeRes(res); checkNoticeRes(res);
}); });
pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkNoticeRes(res); checkNoticeRes(res);
}); });
pinusClient.request('guild.guildHandler.getMyGuildInfo', {}, (res) => { pinusClient.request('guild.guildHandler.getMyGuildInfo', {}, (res) => {
@@ -359,8 +359,8 @@ describe('聊天测试', function () {
expect(setRes.data.notice).to.be.equal(newNotice); expect(setRes.data.notice).to.be.equal(newNotice);
setTimeout(() => { setTimeout(() => {
expect(msgReceiveCnt).to.be.equal(2); expect(msgReceiveCnt).to.be.equal(2);
pinusClientT.off(ON_GROUP_MSG_ROUTE); pinusClientT.off(PUSH_ROUTE.GROUP_MSG);
pinusClient.off(ON_GROUP_MSG_ROUTE); pinusClient.off(PUSH_ROUTE.GROUP_MSG);
done(); done();
}, 500); }, 500);
}); });
+4 -4
View File
@@ -168,10 +168,10 @@ describe('寻宝创建队伍', function() {
expect(JSON.parse(res.data.content).teamCode).to.be.equal(teamCode); expect(JSON.parse(res.data.content).teamCode).to.be.equal(teamCode);
msgReceiveCnt += 1; msgReceiveCnt += 1;
} }
pinusClientT.on(PUSH_ROUTE.PRIVATE_MSG, (res) => { pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkInviteRes(res); checkInviteRes(res);
}); });
pinusClient.on(PUSH_ROUTE.PRIVATE_MSG, (res) => { pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkInviteRes(res); checkInviteRes(res);
}); });
pinusClient.request('battle.comBattleHandler.createTeam', createTeamParms, (res) => { pinusClient.request('battle.comBattleHandler.createTeam', createTeamParms, (res) => {
@@ -246,12 +246,12 @@ describe('寻宝创建队伍', function() {
expect(msg.content).to.be.equal(MSG_CONTENT); expect(msg.content).to.be.equal(MSG_CONTENT);
} }
pinusClientT.on(PUSH_ROUTE.PRIVATE_MSG, (res) => { pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkSuccessResponse(res); checkSuccessResponse(res);
checkMsg(res.data); checkMsg(res.data);
msgReceiveCnt += 1; msgReceiveCnt += 1;
}); });
pinusClient.on(PUSH_ROUTE.PRIVATE_MSG, (res) => { pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => {
checkSuccessResponse(res); checkSuccessResponse(res);
checkMsg(res.data); checkMsg(res.data);
msgReceiveCnt += 1; msgReceiveCnt += 1;