拍卖行:出价、关注接口和测试用例
This commit is contained in:
@@ -4,6 +4,10 @@ import { PinusWSClient } from 'pinus-robot-plugin';
|
||||
import { expect } from 'chai';
|
||||
import { checkSuccessResponse } from './CheckPatten';
|
||||
import { DEBUG_MAGIC_WORD, AUCTION_SOURCE } from '../app/consts';
|
||||
import { LOT_STATUS } from '../../shared/consts';
|
||||
|
||||
const GOOD_ID_TIEJIAN = 1;
|
||||
const GOOD_ID_GANGJIAN = 2;
|
||||
|
||||
function checkLot(lot) {
|
||||
expect(lot.auctionStage).to.be.a('number');
|
||||
@@ -21,6 +25,31 @@ function checkLot(lot) {
|
||||
expect(Date.parse(lot.end)).to.be.a('number');
|
||||
}
|
||||
|
||||
function checkLots(lots) {
|
||||
for (let lot of lots) {
|
||||
checkLot(lot);
|
||||
}
|
||||
}
|
||||
|
||||
function checkDividend(dividend) {
|
||||
expect(dividend.sourceType).to.be.a('number');
|
||||
expect(dividend.sourceCode).to.be.a('string');
|
||||
expect(dividend.serverId).to.be.a('number');
|
||||
expect(dividend.guildCode).to.be.a('string');
|
||||
expect(dividend.code).to.be.a('string');
|
||||
expect(dividend.status).to.be.a('number');
|
||||
expect(dividend.totalPrice).to.be.a('number');
|
||||
expect(dividend.lots).to.be.an('array');
|
||||
expect(dividend.dividends).to.be.an('array');
|
||||
expect(Date.parse(dividend.begin)).to.be.a('number');
|
||||
}
|
||||
|
||||
function checkDividends(dividends) {
|
||||
for (let dividend of dividends) {
|
||||
checkDividend(dividend);
|
||||
}
|
||||
}
|
||||
|
||||
describe('拍卖行测试', function() {
|
||||
let pinusClient: PinusWSClient;
|
||||
let pinusClientT: PinusWSClient; // 用做测试队友
|
||||
@@ -53,7 +82,7 @@ describe('拍卖行测试', function() {
|
||||
|
||||
it('添加拍品', function(done) {
|
||||
const sourceCode = Math.random().toString(36).slice(-8);
|
||||
pinusClient.request('battle.auctionHandler.debugAddLots', { magicWord: DEBUG_MAGIC_WORD, sourceType: AUCTION_SOURCE.GATE, sourceCode, rewards: [{ id: 1, count: 1 }, { id: 2, count: 2 }] }, (res) => {
|
||||
pinusClient.request('battle.auctionHandler.debugAddLots', { magicWord: DEBUG_MAGIC_WORD, sourceType: AUCTION_SOURCE.GATE, sourceCode, rewards: [{ id: GOOD_ID_TIEJIAN, count: 1 }, { id: GOOD_ID_GANGJIAN, count: 2 }] }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.lots).to.be.an('array');
|
||||
for (let lot of res.data.lots) {
|
||||
@@ -65,35 +94,98 @@ describe('拍卖行测试', function() {
|
||||
|
||||
it('获取拍卖行数据', function(done) {
|
||||
pinusClient.request('battle.auctionHandler.getAuction', {}, (res) => {
|
||||
checkSuccessResponse(res, false);
|
||||
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);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('出价', function(done) {
|
||||
pinusClient.request('battle.auctionHandler.offer', { code: '', max: false }, (res) => {
|
||||
// checkSuccessResponse(res, false);
|
||||
done();
|
||||
it('出价,竞价和一口价', function(done) {
|
||||
let gid = null;
|
||||
pinusClient.on('onEquipAdd', (res) => {
|
||||
checkSuccessResponse(res);
|
||||
expect(res.data.equipInfos).to.be.an('array');
|
||||
for (let info of res.data.equipInfos) {
|
||||
expect(info.id).to.be.equal(gid);
|
||||
}
|
||||
});
|
||||
pinusClient.request('battle.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('battle.auctionHandler.offer', { code: unsoldLots[0].code, max: false }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkLot(res.data.lot);
|
||||
checkDividend(res.data.dividend);
|
||||
expect(res.data.lot.curBuyer).to.be.equal(roleInfo.roleId);
|
||||
done();
|
||||
});
|
||||
unsoldLots.shift();
|
||||
if (unsoldLots.length === 0) {
|
||||
console.warn('没有测试一口价的情况');
|
||||
done();
|
||||
return;
|
||||
}
|
||||
gid = unsoldLots[0].gid;
|
||||
pinusClient.request('battle.auctionHandler.offer', { code: unsoldLots[0].code, max: true }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkLot(res.data.lot);
|
||||
checkDividend(res.data.dividend);
|
||||
expect(res.data.lot.curBuyer).to.be.equal(roleInfo.roleId);
|
||||
setTimeout(() => {
|
||||
done();
|
||||
}, 100);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('出一口价', function(done) {
|
||||
pinusClient.request('battle.auctionHandler.offer', { code: '', max: true }, (res) => {
|
||||
// checkSuccessResponse(res, false);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
it('关注', function(done) {
|
||||
pinusClient.request('battle.auctionHandler.watchLot', { code: '' }, (res) => {
|
||||
checkSuccessResponse(res, false);
|
||||
done();
|
||||
it('关注后取关', function(done) {
|
||||
pinusClient.request('battle.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;
|
||||
}
|
||||
const code = res.data.lots[0].code;
|
||||
pinusClient.request('battle.auctionHandler.watchLot', { code }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkLot(res.data.lot);
|
||||
expect(res.data.lot.watchingRoles.indexOf(roleInfo.roleId)).to.be.above(-1);
|
||||
pinusClient.request('battle.auctionHandler.unWatchLot', { code }, (res) => {
|
||||
checkSuccessResponse(res);
|
||||
checkLot(res.data.lot);
|
||||
expect(res.data.lot.watchingRoles.indexOf(roleInfo.roleId)).to.be.equal(-1);
|
||||
done();
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
it('查看分红', function(done) {
|
||||
pinusClient.request('battle.auctionHandler.checkDividend', {}, (res) => {
|
||||
checkSuccessResponse(res, false);
|
||||
checkSuccessResponse(res);
|
||||
checkDividends(res.data.dividends);
|
||||
done();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user