diff --git a/game-server/test/Client.ts b/game-server/test/Client.ts index 3e2aecd6d..368ee4764 100644 --- a/game-server/test/Client.ts +++ b/game-server/test/Client.ts @@ -1,7 +1,7 @@ import { PinusWSClient } from 'pinus-robot-plugin'; import { expect } from 'chai'; 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'; const request = require('request'); const crypto = require('crypto'); @@ -61,7 +61,7 @@ export class Client { port: port }, (data) => { // 连接成功执行函数 - this._client.on(ON_ADD_CHANNEL_ROUTE, (msg) => { + this._client.on(PUSH_ROUTE.ADD_CHANNEL, (msg) => { checkSuccessResponse(msg); expect(msg.data.roleId).to.be.a('string'); expect(msg.data.channelName).to.be.a('string'); diff --git a/game-server/test/chat.test.ts b/game-server/test/chat.test.ts index 7c11ab7a4..21b525a03 100644 --- a/game-server/test/chat.test.ts +++ b/game-server/test/chat.test.ts @@ -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 'mocha'; import { PinusWSClient } from 'pinus-robot-plugin'; import { expect } from 'chai'; 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 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) { let msgReceiveCnt = 0; const roomId = `${channel}_${channelId}`; - pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { + pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkSuccessResponse(res); checkGroupMsg(res.data, roleInfo.roleId, roomId, TEXT_MSG.content); msgReceiveCnt += 1; }); - pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { + pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkSuccessResponse(res); checkGroupMsg(res.data, roleInfo.roleId, roomId, TEXT_MSG.content); msgReceiveCnt += 1; @@ -57,8 +57,8 @@ function testGroupMsg(pinusClient: PinusWSClient, roleInfo: any, pinusClientT: P checkSuccessResponse(res, false); setTimeout(() => { expect(msgReceiveCnt).to.be.equal(2); - pinusClientT.off(ON_GROUP_MSG_ROUTE); - pinusClient.off(ON_GROUP_MSG_ROUTE); + pinusClientT.off(PUSH_ROUTE.GROUP_MSG); + pinusClient.off(PUSH_ROUTE.GROUP_MSG); done(); }, 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) { // let msgReceiveCnt = 0; -// pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { +// pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => { // checkSuccessResponse(res); // checkHeroInfoStr(res.data.content); // msgReceiveCnt += 1; // }); -// pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { +// pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => { // checkSuccessResponse(res); // checkHeroInfoStr(res.data.content); // msgReceiveCnt += 1; @@ -124,7 +124,7 @@ describe('聊天测试', function () { }); it('两个玩家互相发送', function (done) { - pinusClientT.on(ON_PRIVATE_MSG_ROUTE, (msg) => { + pinusClientT.on(PUSH_ROUTE.PRIVATE_MSG, (msg) => { checkSuccessResponse(msg); expect(msg.data.content).to.equal(TEXT_MSG.content); }); @@ -196,12 +196,12 @@ describe('聊天测试', function () { it('测试系统频道橙将合成消息', function (done) { let msgReceiveCnt = 0; - pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { + pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkSuccessResponse(res); // checkHeroInfoStr(res.data.content); msgReceiveCnt += 1; }); - pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { + pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkSuccessResponse(res); // checkHeroInfoStr(res.data.content); msgReceiveCnt += 1; @@ -214,8 +214,8 @@ describe('聊天测试', function () { checkSuccessResponse(composeRes); setTimeout(() => { expect(msgReceiveCnt).to.be.equal(2); - pinusClientT.off(ON_GROUP_MSG_ROUTE); - pinusClient.off(ON_GROUP_MSG_ROUTE); + pinusClientT.off(PUSH_ROUTE.GROUP_MSG); + pinusClient.off(PUSH_ROUTE.GROUP_MSG); done(); }, 1000); }); @@ -225,12 +225,12 @@ describe('聊天测试', function () { // 材料不足先跳过 it.skip('测试系统频道升六星消息', function (done) { let msgReceiveCnt = 0; - pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { + pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkSuccessResponse(res); // checkHeroInfoStr(res.data.content); msgReceiveCnt += 1; }); - pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { + pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkSuccessResponse(res); // checkHeroInfoStr(res.data.content); msgReceiveCnt += 1; @@ -267,10 +267,10 @@ describe('聊天测试', function () { // checkHeroInfoStr(res.data.content); msgReceiveCnt += 1; } - pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { + pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkHeroInfoRes(res); }); - pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { + pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkHeroInfoRes(res); }); 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); msgReceiveCnt += 1; } - pinusClientT.on(ON_GROUP_MSG_ROUTE, (res) => { + pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkNoticeRes(res); }); - pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => { + pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkNoticeRes(res); }); pinusClient.request('guild.guildHandler.getMyGuildInfo', {}, (res) => { @@ -359,8 +359,8 @@ describe('聊天测试', function () { expect(setRes.data.notice).to.be.equal(newNotice); setTimeout(() => { expect(msgReceiveCnt).to.be.equal(2); - pinusClientT.off(ON_GROUP_MSG_ROUTE); - pinusClient.off(ON_GROUP_MSG_ROUTE); + pinusClientT.off(PUSH_ROUTE.GROUP_MSG); + pinusClient.off(PUSH_ROUTE.GROUP_MSG); done(); }, 500); }); diff --git a/game-server/test/comBattle.test.ts b/game-server/test/comBattle.test.ts index 835a2dc2c..d9f7d56d8 100644 --- a/game-server/test/comBattle.test.ts +++ b/game-server/test/comBattle.test.ts @@ -168,10 +168,10 @@ describe('寻宝创建队伍', function() { expect(JSON.parse(res.data.content).teamCode).to.be.equal(teamCode); msgReceiveCnt += 1; } - pinusClientT.on(PUSH_ROUTE.PRIVATE_MSG, (res) => { + pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkInviteRes(res); }); - pinusClient.on(PUSH_ROUTE.PRIVATE_MSG, (res) => { + pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkInviteRes(res); }); pinusClient.request('battle.comBattleHandler.createTeam', createTeamParms, (res) => { @@ -246,12 +246,12 @@ describe('寻宝创建队伍', function() { expect(msg.content).to.be.equal(MSG_CONTENT); } - pinusClientT.on(PUSH_ROUTE.PRIVATE_MSG, (res) => { + pinusClientT.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkSuccessResponse(res); checkMsg(res.data); msgReceiveCnt += 1; }); - pinusClient.on(PUSH_ROUTE.PRIVATE_MSG, (res) => { + pinusClient.on(PUSH_ROUTE.GROUP_MSG, (res) => { checkSuccessResponse(res); checkMsg(res.data); msgReceiveCnt += 1;