测试:抽象网络请求返回值成功检查;添加寻宝匹配初步测试
This commit is contained in:
@@ -3,17 +3,21 @@ import { COM_BTL_QUALITY } from './../app/consts/constModules/itemConst';
|
||||
import 'mocha';
|
||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||
import { expect } from 'chai';
|
||||
import { checkSuccessResponse } from './CheckPatten';
|
||||
describe('寻宝创建队伍', function() {
|
||||
var pinusClient: PinusWSClient;
|
||||
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) {
|
||||
if (c.client && cT.client) {
|
||||
pinusClient = c.client;
|
||||
pinusClientT = cT.client;
|
||||
clearInterval(timer);
|
||||
done();
|
||||
}
|
||||
@@ -22,14 +26,38 @@ describe('寻宝创建队伍', function() {
|
||||
|
||||
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);
|
||||
});
|
||||
} {
|
||||
console.warn('未测试到匹配成功的情况');
|
||||
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');
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.teamCode).to.be.a('string');
|
||||
expect(res.data.roleStatus).to.be.an('array');
|
||||
res.data.roleStatus.forEach(roleSt => {
|
||||
@@ -45,8 +73,7 @@ describe('寻宝创建队伍', function() {
|
||||
|
||||
it('搜索队伍再取消', function(done) {
|
||||
pinusClient.request('battle.comBattleHandler.searchTeam', searchTeamParms, (res) => {
|
||||
expect(res).to.be.an('object');
|
||||
expect(res.code).equal(0);
|
||||
checkSuccessResponse(res, false);
|
||||
if (!res.data) {
|
||||
pinusClient.request('battle.comBattleHandler.cancelSearch', {}, (cancelRes) => {
|
||||
expect(cancelRes).to.be.an('object');
|
||||
@@ -63,9 +90,7 @@ describe('寻宝创建队伍', function() {
|
||||
|
||||
it('查询可招募或助战的次数', function(done) {
|
||||
pinusClient.request('battle.comBattleHandler.getComBtlCnt', {}, (res) => {
|
||||
expect(res).to.be.an('object');
|
||||
expect(res.code).equal(0);
|
||||
expect(res.data).to.be.an('object');
|
||||
checkSuccessResponse(res);
|
||||
console.log('getComBtlCnt', res.data);
|
||||
expect(res.data.assistCnt).to.be.an('array');
|
||||
res.data.assistCnt.forEach(cnt => {
|
||||
@@ -82,9 +107,7 @@ describe('寻宝创建队伍', function() {
|
||||
|
||||
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');
|
||||
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');
|
||||
|
||||
Reference in New Issue
Block a user