151 lines
6.4 KiB
TypeScript
151 lines
6.4 KiB
TypeScript
import { COM_TEAM_STATUS, DEFAULT_HEROES } from './../../shared/consts/consts';
|
|
import { Client } from './Client';
|
|
import { COM_BTL_QUALITY } from './../app/consts/constModules/itemConst';
|
|
import 'mocha';
|
|
import { PinusWSClient } from 'pinus-robot-plugin';
|
|
import { expect } from 'chai';
|
|
import { checkDisplayItems, checkSuccessResponse } from './CheckPatten';
|
|
describe('寻宝创建队伍', function() {
|
|
let pinusClient: PinusWSClient;
|
|
let pinusClientT: PinusWSClient; // 用做测试队友
|
|
|
|
const createTeamParms = {blueprtId: 33001, pub: true, ceLimit: 0};
|
|
const searchTeamParms = {qualityArr: COM_BTL_QUALITY};
|
|
|
|
beforeEach(function(done) {
|
|
const c = new Client();
|
|
const cT = new Client('13121622738');
|
|
const timer = setInterval(() => {
|
|
if (c.client && cT.client) {
|
|
pinusClient = c.client;
|
|
pinusClientT = cT.client;
|
|
clearInterval(timer);
|
|
done();
|
|
}
|
|
}, 500);
|
|
});
|
|
|
|
afterEach(function(done) {
|
|
pinusClient.disconnect();
|
|
pinusClientT.disconnect();
|
|
done();
|
|
});
|
|
|
|
it('两个玩家匹配到结算', function(done) {
|
|
pinusClient.request('battle.comBattleHandler.createTeam', createTeamParms, (res) => {
|
|
checkSuccessResponse(res);
|
|
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');
|
|
});
|
|
pinusClientT.request('battle.comBattleHandler.searchTeam', searchTeamParms, (searchRes) => {
|
|
console.log('searchRes:', searchRes);
|
|
checkSuccessResponse(searchRes, false);
|
|
if (searchRes.data && searchRes.data.teamCode) {
|
|
expect(searchRes.data).to.be.an('object');
|
|
expect(searchRes.data.teamCode).to.be.a('string');
|
|
pinusClientT.request('battle.comBattleHandler.joinTeam', { teamCode: searchRes.data.teamCode, isFrd: false }, (joinRes) => {
|
|
checkSuccessResponse(joinRes);
|
|
if (searchRes.data.teamCode === res.data.teamCode) {
|
|
const { teamCode } = res.data;
|
|
pinusClient.request('battle.comBattleHandler.startBattle', { teamCode }, (startRes) => {
|
|
checkSuccessResponse(startRes, false);
|
|
pinusClient.request('battle.comBattleHandler.setupHeroes', { teamCode, heroes: DEFAULT_HEROES}, (setupRes) => {
|
|
checkSuccessResponse(setupRes, false);
|
|
const bossHurts = [2001, 2002, 2003, 2004, 2005].map(value => {return {dataId: value, hurtHp: -1000}});
|
|
pinusClient.request('battle.comBattleHandler.action', {teamCode, bossHurts, killed: [], curRound: 1}, (actionRes) => {
|
|
checkSuccessResponse(actionRes, false);
|
|
pinusClient.request('battle.comBattleHandler.getComBtlStatus', { teamCode }, (statusRes) => {
|
|
checkSuccessResponse(statusRes);
|
|
expect(statusRes.data.teamInfo).to.be.an('object');
|
|
expect(statusRes.data.teamInfo.status).to.equal(COM_TEAM_STATUS.WIN);
|
|
pinusClient.request('battle.comBattleHandler.comBattleEnd', { teamCode }, (endRes) => {
|
|
checkSuccessResponse(endRes);
|
|
const { battleGoods, teamInfo, actordata, lv, exp, kingExp} = endRes.data;
|
|
checkDisplayItems(battleGoods);
|
|
expect(teamInfo).to.be.an('object');
|
|
expect(actordata).to.be.an('array');
|
|
expect(lv).to.be.a('number');
|
|
expect(exp).to.be.a('number');
|
|
expect(kingExp).to.be.a('number');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
})
|
|
});
|
|
} else {
|
|
console.warn('未测试到开战情况');
|
|
done();
|
|
}
|
|
});
|
|
} else {
|
|
console.warn('未测试到匹配成功的情况');
|
|
done();
|
|
}
|
|
});
|
|
});
|
|
});
|
|
|
|
it('创建队伍并解散', function(done) {
|
|
pinusClient.request('battle.comBattleHandler.createTeam', createTeamParms, (res) => {
|
|
checkSuccessResponse(res);
|
|
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) {
|
|
pinusClient.request('battle.comBattleHandler.searchTeam', searchTeamParms, (res) => {
|
|
checkSuccessResponse(res, false);
|
|
if (!res.data) {
|
|
pinusClient.request('battle.comBattleHandler.cancelSearch', {}, (cancelRes) => {
|
|
expect(cancelRes).to.be.an('object');
|
|
expect(cancelRes.code).equal(0);
|
|
done();
|
|
});
|
|
} else {
|
|
expect(res.data).to.be.an('object');
|
|
expect(res.data.teamCode).to.be.a('string');
|
|
done();
|
|
}
|
|
});
|
|
});
|
|
|
|
it('查询可招募或助战的次数', function(done) {
|
|
pinusClient.request('battle.comBattleHandler.getComBtlCnt', {}, (res) => {
|
|
checkSuccessResponse(res);
|
|
expect(res.data.assistCnt).to.be.an('array');
|
|
res.data.assistCnt.forEach(cnt => {
|
|
expect(cnt).to.be.a('number');
|
|
});
|
|
expect(res.data.blueprts).to.be.an('array');
|
|
res.data.blueprts.forEach(item => {
|
|
expect(item.id).to.be.a('number');
|
|
expect(item.count).to.be.a('number');
|
|
});
|
|
done();
|
|
});
|
|
});
|
|
|
|
it('获取寻宝记录', function(done) {
|
|
pinusClient.request('battle.comBattleHandler.getTeamRec', {}, (res) => {
|
|
checkSuccessResponse(res);
|
|
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();
|
|
});
|
|
});
|
|
});
|