70 lines
2.1 KiB
TypeScript
70 lines
2.1 KiB
TypeScript
import 'mocha';
|
|
import { PinusWSClient, PinusWSClientEvent } from 'pinus-robot-plugin';
|
|
import { expect } from 'chai';
|
|
describe('寻宝创建队伍', function() {
|
|
// it('异步请求应该返回一个对象', function(done){
|
|
// request
|
|
// .get('https://api.github.com')
|
|
// .end(function(err, res){
|
|
// expect(res).to.be.an('object');
|
|
// done();
|
|
// });
|
|
// });
|
|
var pinusClient;
|
|
var roleInfo;
|
|
|
|
beforeEach(function(done) {
|
|
pinusClient = new PinusWSClient();
|
|
pinusClient.on(PinusWSClientEvent.EVENT_IO_ERROR, (event) => {
|
|
// 错误处理
|
|
// console.error('error', event);
|
|
done();
|
|
});
|
|
pinusClient.on(PinusWSClientEvent.EVENT_CLOSE, function(event) {
|
|
// 关闭处理
|
|
// console.error('close', event);
|
|
done();
|
|
});
|
|
pinusClient.on(PinusWSClientEvent.EVENT_HEART_BEAT_TIMEOUT, function(event) {
|
|
// 心跳timeout
|
|
// console.error('heart beat timeout', event);
|
|
});
|
|
pinusClient.on(PinusWSClientEvent.EVENT_KICK, function(event) {
|
|
// 踢出
|
|
// console.error('kick', event);
|
|
});
|
|
let host = '127.0.0.1';
|
|
let port = '3050';
|
|
pinusClient.init({
|
|
host: host,
|
|
port: port
|
|
}, (data) => {
|
|
// 连接成功执行函数
|
|
console.log('gate连接成功', data);
|
|
// done();
|
|
pinusClient.request('connector.entryHandler.enter', {token:'mgn0njiajb6kapid3eekvt7tssxelig9zi2oq2bzkxr4zzi9w9', serverId: 1} , (ret) => {
|
|
// 消息回调
|
|
console.log('connector返回', JSON.stringify(ret));
|
|
roleInfo = ret.role;
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|
|
afterEach(function(done) {
|
|
pinusClient.disconnect();
|
|
done();
|
|
});
|
|
|
|
it('直接返回队伍', function(done) {
|
|
pinusClient.request('battle.comBattleHandler.createTeam', {blueprtId: 33001, pub: true, ceLimit: 0}, (res) => {
|
|
expect(res).to.be.an('object');
|
|
expect(res.code).equal(0);
|
|
expect(res.data).to.be.an('object');
|
|
expect(res.data.teamCode).to.be.a('string');
|
|
expect(res.data.roleStatus).to.be.an('array');
|
|
done();
|
|
});
|
|
});
|
|
});
|