111 lines
4.0 KiB
TypeScript
111 lines
4.0 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;
|
|
|
|
const loginParms = {serverId: 1};
|
|
const createTeamParms = {blueprtId: 33001, pub: true, ceLimit: 0};
|
|
const searchTeamParms = {qualityArr: [1, 2, 3, 4, 5]};
|
|
|
|
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连接成功');
|
|
// console.log('gate连接成功', data);
|
|
// done();
|
|
pinusClient.request('connector.entryHandler.debugQueryToken', {tel: '13911134885', magicWord: 'zyz666server518'}, (res) => {
|
|
expect(res).to.be.an('object');
|
|
expect(res.data).to.be.an('object');
|
|
expect(res.data.token).to.be.an('string');
|
|
pinusClient.request('connector.entryHandler.enter', {...loginParms, ...res.data}, (ret) => {
|
|
// 消息回调
|
|
console.log('connector返回');
|
|
// console.log('connector返回', JSON.stringify(ret));
|
|
roleInfo = ret.role;
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
});
|
|
|
|
afterEach(function(done) {
|
|
pinusClient.disconnect();
|
|
done();
|
|
});
|
|
|
|
it('创建队伍并解散', function(done) {
|
|
pinusClient.request('battle.comBattleHandler.createTeam', createTeamParms, (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');
|
|
res.data.roleStatus.forEach(roleSt => {
|
|
expect(roleSt).to.have.all.keys('roleId', 'roleName', 'isCap', 'isFrd', 'headHid', 'sHid', 'topFiveCe', 'lv', 'isRobot', 'heroes', 'killed', 'totalDmg', 'frdRatio');
|
|
});
|
|
pinusClient.request('battle.comBattleHandler.dismiss', {teamCode: res.data.teamCode}, (dismissRes) => {
|
|
expect(dismissRes).to.be.an('object');
|
|
expect(dismissRes.code).equal(0);
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
|
|
// it('加入队伍,机器人的话直接开战', function(done) {
|
|
// this.timeout(65 * 1000);
|
|
// pinusClient.request('battle.comBattleHandler.searchTeam', searchTeamParms, (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');
|
|
// });
|
|
// });
|
|
|
|
it('获取寻宝记录', function(done) {
|
|
pinusClient.request('battle.comBattleHandler.getTeamRec', {}, (res) => {
|
|
expect(res).to.be.an('object');
|
|
expect(res.code).equal(0);
|
|
expect(res.data).to.be.an('object');
|
|
expect(res.data.teamInfos).to.be.an('array');
|
|
res.data.teamInfos.forEach(info => {
|
|
expect(info).to.have.contains.keys('teamCode', 'roleIds', 'pub', 'blueprtId', 'quality', 'status', 'roleStatus', 'capId', 'ceLimit', 'roleCnt', 'bossHpArr', 'createdAt');
|
|
});
|
|
done();
|
|
});
|
|
});
|
|
});
|