43 lines
1.3 KiB
TypeScript
43 lines
1.3 KiB
TypeScript
import { PinusWSClient } from 'pinus-robot-plugin';
|
|
import { expect } from 'chai';
|
|
import { checkSuccessResponse } from './CheckPatten';
|
|
import { ON_ADD_CHANNEL_ROUTE } from '../app/consts';
|
|
|
|
export class Client {
|
|
private _client;
|
|
private _roleInfo;
|
|
constructor(tel: string = '13636354764') {
|
|
this._client = new PinusWSClient();
|
|
let host = '127.0.0.1';
|
|
let port = '3050';
|
|
this._client.init({
|
|
host: host,
|
|
port: port
|
|
}, (data) => {
|
|
// 连接成功执行函数
|
|
this._client.request('connector.entryHandler.debugQueryToken', { tel, magicWord: 'zyz666server518' }, (res) => {
|
|
checkSuccessResponse(res);
|
|
expect(res.data.token).to.be.an('string');
|
|
this._client.on(ON_ADD_CHANNEL_ROUTE, (msg) => {
|
|
checkSuccessResponse(msg);
|
|
expect(msg.data.roleId).to.be.a('string');
|
|
expect(msg.data.channelName).to.be.a('string');
|
|
});
|
|
this._client.request('connector.entryHandler.enter', { serverId: 1, ...res.data }, (enterRes) => {
|
|
// 消息回调
|
|
checkSuccessResponse(enterRes);
|
|
expect(enterRes.data.role).to.be.an('object');
|
|
this._roleInfo = enterRes.data.role;
|
|
});
|
|
});
|
|
});
|
|
}
|
|
|
|
get roleInfo() {
|
|
return this._roleInfo;
|
|
}
|
|
|
|
get client() {
|
|
return this._client;
|
|
}
|
|
} |