测试:寻宝正常匹配的完整测试
FIXME:protobuf 中的 onItemUpdate 和测试有冲突
This commit is contained in:
@@ -4,18 +4,19 @@ module.exports = {
|
|||||||
'required string from': 2,
|
'required string from': 2,
|
||||||
'required string target': 3
|
'required string target': 3
|
||||||
},
|
},
|
||||||
'onItemUpdate': {
|
// TODO 检查 protobuf 和测试冲突的原因
|
||||||
'message Data': {
|
// 'onItemUpdate': {
|
||||||
"message Good": {
|
// 'message Data': {
|
||||||
'required uInt32 id': 1,
|
// "message Good": {
|
||||||
'required uInt32 count': 2,
|
// 'required uInt32 id': 1,
|
||||||
},
|
// 'required uInt32 count': 2,
|
||||||
'repeated Good goods': 1,
|
// },
|
||||||
},
|
// 'repeated Good goods': 1,
|
||||||
'required string msg': 1,
|
// },
|
||||||
'required uInt32 code': 2,
|
// 'required string msg': 1,
|
||||||
'required Data data': 3
|
// 'required uInt32 code': 2,
|
||||||
},
|
// 'required Data data': 3
|
||||||
|
// },
|
||||||
'onPlayerCeUpdate': {
|
'onPlayerCeUpdate': {
|
||||||
'message Data': {
|
'message Data': {
|
||||||
"message Hero": {
|
"message Hero": {
|
||||||
|
|||||||
@@ -6,4 +6,12 @@ export function checkSuccessResponse(response, withData = true) {
|
|||||||
if (withData) {
|
if (withData) {
|
||||||
expect(response.data).to.be.an('object');
|
expect(response.data).to.be.an('object');
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export function checkDisplayItems(items) {
|
||||||
|
expect(items).to.be.an('array');
|
||||||
|
items.forEach(item => {
|
||||||
|
expect(item.id).to.be.a('number');
|
||||||
|
expect(item.count).to.be.a('number');
|
||||||
|
})
|
||||||
}
|
}
|
||||||
@@ -1,9 +1,10 @@
|
|||||||
|
import { COM_TEAM_STATUS, DEFAULT_HEROES } from './../../shared/consts/consts';
|
||||||
import { Client } from './Client';
|
import { Client } from './Client';
|
||||||
import { COM_BTL_QUALITY } from './../app/consts/constModules/itemConst';
|
import { COM_BTL_QUALITY } from './../app/consts/constModules/itemConst';
|
||||||
import 'mocha';
|
import 'mocha';
|
||||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { checkSuccessResponse } from './CheckPatten';
|
import { checkDisplayItems, checkSuccessResponse } from './CheckPatten';
|
||||||
describe('寻宝创建队伍', function() {
|
describe('寻宝创建队伍', function() {
|
||||||
let pinusClient: PinusWSClient;
|
let pinusClient: PinusWSClient;
|
||||||
let pinusClientT: PinusWSClient; // 用做测试队友
|
let pinusClientT: PinusWSClient; // 用做测试队友
|
||||||
@@ -44,10 +45,42 @@ describe('寻宝创建队伍', function() {
|
|||||||
if (searchRes.data && searchRes.data.teamCode) {
|
if (searchRes.data && searchRes.data.teamCode) {
|
||||||
expect(searchRes.data).to.be.an('object');
|
expect(searchRes.data).to.be.an('object');
|
||||||
expect(searchRes.data.teamCode).to.be.a('string');
|
expect(searchRes.data.teamCode).to.be.a('string');
|
||||||
pinusClientT.request('battle.comBattleHandler.joinTeam', {teamCode: searchRes.data.teamCode, isFrd: false}, (joinRes) => {
|
pinusClientT.request('battle.comBattleHandler.joinTeam', { teamCode: searchRes.data.teamCode, isFrd: false }, (joinRes) => {
|
||||||
checkSuccessResponse(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('未测试到匹配成功的情况');
|
console.warn('未测试到匹配成功的情况');
|
||||||
done();
|
done();
|
||||||
}
|
}
|
||||||
@@ -91,7 +124,6 @@ describe('寻宝创建队伍', function() {
|
|||||||
it('查询可招募或助战的次数', function(done) {
|
it('查询可招募或助战的次数', function(done) {
|
||||||
pinusClient.request('battle.comBattleHandler.getComBtlCnt', {}, (res) => {
|
pinusClient.request('battle.comBattleHandler.getComBtlCnt', {}, (res) => {
|
||||||
checkSuccessResponse(res);
|
checkSuccessResponse(res);
|
||||||
console.log('getComBtlCnt', res.data);
|
|
||||||
expect(res.data.assistCnt).to.be.an('array');
|
expect(res.data.assistCnt).to.be.an('array');
|
||||||
res.data.assistCnt.forEach(cnt => {
|
res.data.assistCnt.forEach(cnt => {
|
||||||
expect(cnt).to.be.a('number');
|
expect(cnt).to.be.a('number');
|
||||||
|
|||||||
Reference in New Issue
Block a user