聊天:加入玩家发起的群聊和测试用例
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, ON_MSG_ROUTE } from './../app/consts';
|
||||
import { DEFAULT_MSG_PER_PAGE, MSG_TYPE, ON_MSG_ROUTE, ON_GROUP_MSG_ROUTE, CHANNEL_PREFIX } from './../app/consts';
|
||||
import { Client } from './Client';
|
||||
import 'mocha';
|
||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||
@@ -13,6 +13,40 @@ function sendPrivateMessageParm(targetRoleInfo, msg) {
|
||||
return result;
|
||||
}
|
||||
|
||||
function sendGroupMessageParm(channel, channelId, msg) {
|
||||
const result = {channel, channelId, ...msg};
|
||||
return result;
|
||||
}
|
||||
|
||||
function checkGroupMsg(msg, roleId, roomId, content) {
|
||||
expect(msg.content).to.equal(TEXT_MSG.content);
|
||||
expect(msg.roleId).to.equal(roleId);
|
||||
expect(msg.content).to.equal(content);
|
||||
expect(msg.roomId).to.equal(roomId);
|
||||
}
|
||||
|
||||
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) => {
|
||||
checkSuccessResponse(res);
|
||||
checkGroupMsg(res.data, roleInfo.roleId, roomId, TEXT_MSG.content);
|
||||
msgReceiveCnt += 1;
|
||||
});
|
||||
pinusClient.on(ON_GROUP_MSG_ROUTE, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkGroupMsg(res.data, roleInfo.roleId, roomId, TEXT_MSG.content);
|
||||
msgReceiveCnt += 1;
|
||||
});
|
||||
pinusClient.request('chat.chatHandler.sendGroupMessage', sendGroupMessageParm(channel, channelId, TEXT_MSG), (res) => {
|
||||
checkSuccessResponse(res, false);
|
||||
setTimeout(() => {
|
||||
expect(msgReceiveCnt).to.be.equal(2);
|
||||
done();
|
||||
}, 1000);
|
||||
});
|
||||
}
|
||||
|
||||
describe('聊天测试', function() {
|
||||
let pinusClient: PinusWSClient;
|
||||
let pinusClientT: PinusWSClient; // 用做测试队友
|
||||
@@ -72,4 +106,12 @@ describe('聊天测试', function() {
|
||||
})
|
||||
}, 1000);
|
||||
});
|
||||
|
||||
it('测试系统频道消息', function(done) {
|
||||
testGroupMsg(pinusClient, roleInfo, pinusClientT, CHANNEL_PREFIX.SYS, roleInfo.serverId, done);
|
||||
});
|
||||
|
||||
it('测试世界频道消息', function(done) {
|
||||
testGroupMsg(pinusClient, roleInfo, pinusClientT, CHANNEL_PREFIX.WORLD, roleInfo.serverId, done);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user