252 lines
7.6 KiB
TypeScript
252 lines
7.6 KiB
TypeScript
import { Client } from './Client';
|
||
import 'mocha';
|
||
import { PinusWSClient } from 'pinus-robot-plugin';
|
||
import { expect } from 'chai';
|
||
import { checkSuccessResponse } from './CheckPatten';
|
||
import { BLOCK_OPEATE, RANK_TYPE } from '../app/consts';
|
||
|
||
describe('排行榜测试', function() {
|
||
|
||
let pinusClient: PinusWSClient;
|
||
let roleInfo;
|
||
|
||
before(function(done) {
|
||
const c = new Client();
|
||
const timer = setInterval(() => {
|
||
if (c.client) {
|
||
pinusClient = c.client;
|
||
roleInfo = c.roleInfo;
|
||
clearInterval(timer);
|
||
done();
|
||
}
|
||
}, 500);
|
||
});
|
||
|
||
after(function(done) {
|
||
pinusClient.disconnect();
|
||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||
setTimeout(() => {
|
||
done();
|
||
}, 500);
|
||
});
|
||
|
||
// it('获取排行榜总览页面', function(done) {
|
||
// pinusClient.request('role.rankHandler.getGeneralRank', { } , (res) => {
|
||
// checkSuccessResponse(res);
|
||
// expect(res.data.role).to.be.an('array');
|
||
// res.data.role.forEach(data=> {
|
||
// expect(data.type).to.be.a('number');
|
||
// expect(data.roleId).to.be.a('string');
|
||
// expect(data.roleName).to.be.a('string');
|
||
// expect(data.head).to.be.a('number');
|
||
// expect(data.frame).to.be.a('number');
|
||
// expect(data.spine).to.be.a('number');
|
||
// expect(data.lv).to.be.a('number');
|
||
// expect(data.guildName).to.be.a('string');
|
||
// expect(data.ce).to.be.a('number');
|
||
// expect(data.num).to.be.a('number');
|
||
// expect(data.received).to.be.a('array');
|
||
// data.received.forEach(id=> {
|
||
// expect(id).to.be.a('number');
|
||
// })
|
||
// })
|
||
// expect(res.data.battle).to.be.an('array');
|
||
// res.data.battle.forEach(data=> {
|
||
// expect(data.type).to.be.a('number');
|
||
// expect(data.roleId).to.be.a('string');
|
||
// expect(data.roleName).to.be.a('string');
|
||
// expect(data.guildName).to.be.a('string');
|
||
// expect(data.hid).to.be.a('number');
|
||
// expect(data.skinId).to.be.a('number');
|
||
// expect(data.num).to.be.a('number');
|
||
// expect(data.received).to.be.a('array');
|
||
// data.received.forEach(id=> {
|
||
// expect(id).to.be.a('number');
|
||
// })
|
||
// })
|
||
// });
|
||
// done();
|
||
// });
|
||
|
||
// it('获取玩家最强阵容排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getRank', { type: RANK_TYPE.TOP_LINTUP } , (res) => {
|
||
// checkParamWithLineup(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
|
||
// it('获取玩家最强武将排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getRank', { type: RANK_TYPE.TOP_HERO } , (res) => {
|
||
// checkParamWithLineup(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
|
||
// it('获取玩家武将数量排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getRank', { type: RANK_TYPE.HERO_NUM } , (res) => {
|
||
// checkParam(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
|
||
// it('获取玩家主公等级排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getRank', { type: RANK_TYPE.USER_LV } , (res) => {
|
||
// checkParam(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
|
||
// it('获取玩家总战力排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getRank', { type: RANK_TYPE.SUM_CE } , (res) => {
|
||
// checkParam(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
|
||
// it('获取镇念塔排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getRank', { type: RANK_TYPE.TOWER } , (res) => {
|
||
// checkParam(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
|
||
// it('获取秘境排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getRank', { type: RANK_TYPE.DUNGEON } , (res) => {
|
||
// checkParamWithLineup(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
|
||
// it('获取主线排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getRank', { type: RANK_TYPE.MAIN } , (res) => {
|
||
// checkParam(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
|
||
// it('获取精英排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getRank', { type: RANK_TYPE.MAIN_ELITE } , (res) => {
|
||
// checkParam(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
|
||
// it('获取军团排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getGuildRank', { type: RANK_TYPE.GUILD_LV } , (res) => {
|
||
// checkGuildParam(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
|
||
// it('获取军团活跃排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getGuildRank', { type: RANK_TYPE.GUILD_ACTIVE } , (res) => {
|
||
// checkGuildParam(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
|
||
|
||
// it('获取武将排行榜', function(done) {
|
||
// pinusClient.request('role.rankHandler.getHeroRank', { type: RANK_TYPE.HERO, hid: 19 } , (res) => {
|
||
// checkParamWithLineupAndHero(res);
|
||
// done();
|
||
// });
|
||
// });
|
||
});
|
||
|
||
|
||
function checkParamWithLineupAndHero(res) {
|
||
checkSuccessResponse(res);
|
||
expect(res.data.type).to.be.a('number');
|
||
expect(res.data.ranks).to.be.a('array');
|
||
res.data.ranks.forEach(cur => {
|
||
checkRankParamWithLineupAndHero(cur);
|
||
})
|
||
}
|
||
function checkGuildParam(res) {
|
||
checkSuccessResponse(res);
|
||
expect(res.data.type).to.be.a('number');
|
||
expect(res.data.ranks).to.be.a('array');
|
||
expect(res.data.myRank).to.be.an('object');
|
||
checkGuildRankParam(res.data.myRank);
|
||
res.data.ranks.forEach(cur => {
|
||
checkGuildRankParam(cur);
|
||
})
|
||
}
|
||
|
||
function checkParam(res) {
|
||
checkSuccessResponse(res);
|
||
expect(res.data.type).to.be.a('number');
|
||
expect(res.data.ranks).to.be.a('array');
|
||
expect(res.data.myRank).to.be.an('object');
|
||
checkBasicParam(res.data.myRank);
|
||
res.data.ranks.forEach(cur => {
|
||
checkBasicParam(cur);
|
||
})
|
||
}
|
||
|
||
function checkParamWithLineup(res) {
|
||
checkSuccessResponse(res);
|
||
expect(res.data.type).to.be.a('number');
|
||
expect(res.data.ranks).to.be.a('array');
|
||
expect(res.data.myRank).to.be.an('object');
|
||
checkRankParamWithLineup(res.data.myRank);
|
||
res.data.ranks.forEach(cur => {
|
||
checkRankParamWithLineup(cur);
|
||
})
|
||
}
|
||
|
||
function checkRankParamWithLineup(data) {
|
||
checkBasicParam(data);
|
||
expect(data.lineup).to.be.a('array');
|
||
data.lineup.forEach(cur => {
|
||
checkLineup(cur);
|
||
})
|
||
}
|
||
|
||
function checkRankParamWithLineupAndHero(data) {
|
||
checkBasicParam(data);
|
||
expect(data.lineup).to.be.a('array');
|
||
data.lineup.forEach(cur => {
|
||
checkLineup(cur);
|
||
});
|
||
data.hero.forEach(cur => {
|
||
checkLineup(cur);
|
||
});
|
||
}
|
||
|
||
function checkBasicParam(data) {
|
||
expect(data.rank).to.be.a('number');
|
||
expect(data.num).to.be.a('number');
|
||
expect(data.roleId).to.be.a('string');
|
||
expect(data.roleName).to.be.a('string');
|
||
expect(data.head).to.be.a('number');
|
||
expect(data.frame).to.be.a('number');
|
||
expect(data.spine).to.be.a('number');
|
||
expect(data.lv).to.be.a('number');
|
||
expect(data.guildName).to.be.a('string');
|
||
expect(data.ce).to.be.a('number');
|
||
}
|
||
|
||
function checkLineup(hero) {
|
||
expect(hero.hid).to.be.a('number');
|
||
expect(hero.star).to.be.a('number');
|
||
expect(hero.colorStar).to.be.a('number');
|
||
expect(hero.lv).to.be.a('number');
|
||
expect(hero.quality).to.be.a('number');
|
||
expect(hero.job).to.be.a('number');
|
||
}
|
||
|
||
|
||
function checkGuildRankParam(data) {
|
||
expect(data.rank).to.be.a('number');
|
||
expect(data.num).to.be.a('number');
|
||
expect(data.code).to.be.a('string');
|
||
expect(data.name).to.be.a('string');
|
||
expect(data.icon).to.be.a('number');
|
||
expect(data.lv).to.be.a('number');
|
||
expect(data.memberCnt).to.be.a('number');
|
||
expect(data.leader).to.be.a('object');
|
||
expect(data.leader.roleId).to.be.a('string');
|
||
expect(data.leader.roleName).to.be.a('string');
|
||
} |