排行榜: 获取排行榜

This commit is contained in:
luying
2021-04-12 09:47:15 +08:00
parent 34e02dea89
commit 5dca7b304d
32 changed files with 1077 additions and 290 deletions
+87
View File
@@ -0,0 +1,87 @@
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;
beforeEach(function(done) {
const c = new Client();
const timer = setInterval(() => {
if (c.client) {
pinusClient = c.client;
roleInfo = c.roleInfo;
clearInterval(timer);
done();
}
}, 500);
});
afterEach(function(done) {
pinusClient.disconnect();
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
setTimeout(() => {
done();
}, 500);
});
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();
});
});
});
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 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');
}