拍卖行:领取奖励、查看关注、查看出价的接口实现和测试用例

This commit is contained in:
liangtongchuan
2021-03-19 00:54:52 +08:00
parent 39228e1fc9
commit 63e0d33846
6 changed files with 143 additions and 15 deletions

View File

@@ -3,7 +3,7 @@ import 'mocha';
import { PinusWSClient } from 'pinus-robot-plugin';
import { expect } from 'chai';
import { checkSuccessResponse } from './CheckPatten';
import { DEBUG_MAGIC_WORD, AUCTION_SOURCE } from '../app/consts';
import { DEBUG_MAGIC_WORD, AUCTION_SOURCE, CURRENCY_BY_TYPE, CURRENCY_TYPE } from '../app/consts';
import { LOT_STATUS } from '../../shared/consts';
const GOOD_ID_TIEJIAN = 1;
@@ -191,22 +191,69 @@ describe('拍卖行测试', function() {
});
it('领取分红', function(done) {
pinusClient.request('battle.auctionHandler.getDividend', {}, (res) => {
checkSuccessResponse(res, false);
done();
pinusClient.on('onItemUpdate', (res) => {
checkSuccessResponse(res);
expect(res.data.goods).to.be.an('array');
for (let info of res.data.goods) {
expect(info.id).to.be.equal(CURRENCY_BY_TYPE.get(CURRENCY_TYPE.GOLD));
}
});
pinusClient.request('battle.auctionHandler.debugSetDividendReady', { magicWord: DEBUG_MAGIC_WORD, sourceType: AUCTION_SOURCE.GATE }, (res) => {
checkSuccessResponse(res);
checkDividend(res.data.dividend);
pinusClient.request('battle.auctionHandler.getDividend', { sourceType: AUCTION_SOURCE.GATE }, (res) => {
checkSuccessResponse(res);
expect(res.data.dividend).to.be.an('object');
expect(res.data.dividend.roleId).to.be.a('string');
expect(res.data.dividend.baseNum).to.be.a('number');
expect(res.data.dividend.posNum).to.be.a('number');
expect(res.data.dividend.weekendNum).to.be.a('number');
expect(res.data.dividend.total).to.be.a('number');
expect(res.data.dividend.status).to.be.a('number');
setTimeout(() => {
done();
}, 100);
});
});
});
it('查看我的关注', function(done) {
pinusClient.request('battle.auctionHandler.myOffers', {}, (res) => {
checkSuccessResponse(res, false);
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.myWatching', {}, (res) => {
checkSuccessResponse(res);
checkLots(res.data.lots);
done();
});
});
});
});
it('查看我的拍卖纪录', function(done) {
pinusClient.request('battle.auctionHandler.offerRecs', { count: 10 }, (res) => {
checkSuccessResponse(res, false);
checkSuccessResponse(res);
expect(res.data.bidRecs).to.be.an('array');
for (let bidRec of res.data.bidRecs) {
expect(bidRec.roleId).to.be.a('string');
expect(bidRec.price).to.be.a('number');
expect(Date.parse(bidRec.time)).to.be.a('number');
expect(bidRec.status).to.be.a('number');
}
done();
});
});