测试:pvp测试
This commit is contained in:
@@ -2,7 +2,7 @@ import { Client } from './Client';
|
||||
import 'mocha';
|
||||
import { PinusWSClient } from 'pinus-robot-plugin';
|
||||
import { expect } from 'chai';
|
||||
import { checkSuccessResponse } from './CheckPatten';
|
||||
import { addItemsIfNotEnough, checkSuccessResponse } from './CheckPatten';
|
||||
import { DEBUG_MAGIC_WORD, AUCTION_SOURCE, CURRENCY_BY_TYPE, CURRENCY_TYPE, AUCTION_STAGE, DIVIDEND_STATUS } from '../app/consts';
|
||||
import { LOT_STATUS } from '../../shared/consts';
|
||||
|
||||
@@ -52,19 +52,14 @@ function checkDividends(dividends) {
|
||||
|
||||
describe('拍卖行测试', function () {
|
||||
let pinusClient: PinusWSClient;
|
||||
let pinusClientT: PinusWSClient; // 用做测试队友
|
||||
let roleInfo;
|
||||
let roleInfoT;
|
||||
|
||||
before(function (done) {
|
||||
const c = new Client();
|
||||
const cT = new Client('13121622738');
|
||||
const timer = setInterval(() => {
|
||||
if (c.client && cT.client) {
|
||||
if (c.client) {
|
||||
pinusClient = c.client;
|
||||
roleInfo = c.roleInfo;
|
||||
pinusClientT = cT.client;
|
||||
roleInfoT = cT.roleInfo;
|
||||
clearInterval(timer);
|
||||
done();
|
||||
}
|
||||
@@ -73,7 +68,6 @@ describe('拍卖行测试', function () {
|
||||
|
||||
after(function (done) {
|
||||
pinusClient.disconnect();
|
||||
pinusClientT.disconnect();
|
||||
// disconnect 后等待 500ms,供服务器清理环境、退出频道等
|
||||
setTimeout(() => {
|
||||
done();
|
||||
@@ -118,48 +112,50 @@ describe('拍卖行测试', function () {
|
||||
expect(info.id).to.be.equal(gid);
|
||||
}
|
||||
});
|
||||
pinusClient.request('guild.auctionHandler.getAuction', {}, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.lots).to.be.an('array');
|
||||
checkLots(res.data.lots);
|
||||
expect(res.data.dividends).to.be.an('array');
|
||||
checkDividends(res.data.dividends);
|
||||
if (res.data.lots.length === 0) {
|
||||
console.warn('没有拍品');
|
||||
done();
|
||||
return;
|
||||
}
|
||||
let unsoldLots = res.data.lots.filter(lot => { return lot.status !== LOT_STATUS.SOLD && lot.curBuyer !== roleInfo.roleId });
|
||||
if (unsoldLots.length === 0) {
|
||||
console.warn('没有可出价的拍品');
|
||||
done();
|
||||
return;
|
||||
}
|
||||
pinusClient.request('guild.auctionHandler.offer', { code: unsoldLots[0].code, max: false }, (res) => {
|
||||
addItemsIfNotEnough(roleInfo, pinusClient, 31002, 100000, () => {
|
||||
pinusClient.request('guild.auctionHandler.getAuction', {}, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkLot(res.data.lot);
|
||||
if (res.data.dividend) {
|
||||
checkDividend(res.data.dividend);
|
||||
}
|
||||
expect(res.data.lot.curBuyer).to.be.equal(roleInfo.roleId);
|
||||
|
||||
unsoldLots.shift();
|
||||
if (unsoldLots.length === 0) {
|
||||
console.warn('没有测试一口价的情况');
|
||||
expect(res.data.lots).to.be.an('array');
|
||||
checkLots(res.data.lots);
|
||||
expect(res.data.dividends).to.be.an('array');
|
||||
checkDividends(res.data.dividends);
|
||||
if (res.data.lots.length === 0) {
|
||||
console.warn('没有拍品');
|
||||
done();
|
||||
return;
|
||||
}
|
||||
gid = unsoldLots[0].gid;
|
||||
pinusClient.request('guild.auctionHandler.offer', { code: unsoldLots[0].code, max: true }, (res) => {
|
||||
let unsoldLots = res.data.lots.filter(lot => { return lot.status !== LOT_STATUS.SOLD && lot.curBuyer !== roleInfo.roleId });
|
||||
if (unsoldLots.length === 0) {
|
||||
console.warn('没有可出价的拍品');
|
||||
done();
|
||||
return;
|
||||
}
|
||||
pinusClient.request('guild.auctionHandler.offer', { code: unsoldLots[0].code, max: false }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkLot(res.data.lot);
|
||||
if(res.data.dividend) {
|
||||
if (res.data.dividend) {
|
||||
checkDividend(res.data.dividend);
|
||||
}
|
||||
expect(res.data.lot.curBuyer).to.be.equal(roleInfo.roleId);
|
||||
setTimeout(() => {
|
||||
|
||||
unsoldLots.shift();
|
||||
if (unsoldLots.length === 0) {
|
||||
console.warn('没有测试一口价的情况');
|
||||
done();
|
||||
}, 1000);
|
||||
return;
|
||||
}
|
||||
gid = unsoldLots[0].gid;
|
||||
pinusClient.request('guild.auctionHandler.offer', { code: unsoldLots[0].code, max: true }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkLot(res.data.lot);
|
||||
if(res.data.dividend) {
|
||||
checkDividend(res.data.dividend);
|
||||
}
|
||||
expect(res.data.lot.curBuyer).to.be.equal(roleInfo.roleId);
|
||||
setTimeout(() => {
|
||||
done();
|
||||
}, 1000);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user