获取军团列表测试用例

This commit is contained in:
luying
2021-01-18 16:42:08 +08:00
parent a8965d4185
commit 97216647b2
5 changed files with 168 additions and 19 deletions

View File

@@ -0,0 +1,81 @@
import 'mocha';
import { PinusWSClient, PinusWSClientEvent } from 'pinus-robot-plugin';
import { expect } from 'chai';
describe('军团测试', function() {
// it('异步请求应该返回一个对象', function(done){
// request
// .get('https://api.github.com')
// .end(function(err, res){
// expect(res).to.be.an('object');
// done();
// });
// });
var pinusClient;
var roleInfo;
beforeEach(function(done) {
pinusClient = new PinusWSClient();
pinusClient.on(PinusWSClientEvent.EVENT_IO_ERROR, (event) => {
// 错误处理
// console.error('error', event);
done();
});
pinusClient.on(PinusWSClientEvent.EVENT_CLOSE, function(event) {
// 关闭处理
// console.error('close', event);
done();
});
pinusClient.on(PinusWSClientEvent.EVENT_HEART_BEAT_TIMEOUT, function(event) {
// 心跳timeout
// console.error('heart beat timeout', event);
});
pinusClient.on(PinusWSClientEvent.EVENT_KICK, function(event) {
// 踢出
// console.error('kick', event);
});
let host = '127.0.0.1';
let port = '3050';
pinusClient.init({
host: host,
port: port
}, (data) => {
// 连接成功执行函数
console.log('gate连接成功', data);
// done();
pinusClient.request('connector.entryHandler.enter', {token:'mgn0njiajb6kapid3eekvt7tssxelig9zi2oq2bzkxr4zzi9w9', serverId: 1} , (ret) => {
// 消息回调
console.log('connector返回', JSON.stringify(ret));
roleInfo = ret.role;
done();
});
});
});
afterEach(function(done) {
pinusClient.disconnect();
done();
});
it('获取军团列表', function(done) {
pinusClient.request('battle.guildHandler.getGuildList', {page:1, showPeopleMax: true, name: ""} , (res) => {
console.log(JSON.stringify(res))
// 消息回调
expect(res).to.be.an('object');
expect(res.code).equal(0);
expect(res.data).to.be.an('object');
expect(res.data).to.have.deep.property('list').that.is.an('array');
res.data.list.forEach(list => {
expect(list).to.have.deep.property('code').that.is.a('string');
expect(list).to.have.deep.property('name').that.is.a('string');
expect(list).to.have.deep.property('icon').that.is.a('number');
expect(list).to.have.deep.property('lv').that.is.a('number');
expect(list).to.have.deep.property('peopleNum').that.is.a('number');
expect(list).to.have.deep.property('leader').that.is.a('string');
expect(list).to.have.deep.property('ceCondition').that.is.a('number');
expect(list).to.have.deep.property('quitTime').that.is.a('number');
expect(list).to.have.deep.property('hasApply').that.is.a('boolean');
});
done();
});
});
});