| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 | 'use strict';/** * * * @author Mai * @date * @version */const { app, assert } = require('egg-mock/bootstrap');const Calc = require('../../../app/lib/pay_calc');const PayConst = require('../../../app/const/deal_pay.js');describe('test/app/lib/pay_calc.test.js', () => {    it('test calculate Stage DealPay TotalPrice', function* () {        const ctx = app.mockContext();        // 模拟登录        const postData = {            account: '734406061@qq.com',            project: 'T201711273363',            project_password: 'mai654321',        };        ctx.session = {};        const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);        assert(loginResult);        // 模拟打开标段        ctx.tender = {id: 244};        ctx.tender.data = yield ctx.service.tender.getTender(ctx.tender.id);        ctx.tender.info = yield ctx.service.tenderInfo.getTenderInfo(ctx.tender.id);        // 模拟打开期        ctx.stage = yield ctx.service.stage.getDataByCondition({            id: 43        });        ctx.stage.curTimes = ctx.stage.times;        ctx.stage.curOrder = 0;        const calc = new Calc(ctx, ctx.tender.info.decimal);        const dealPay = yield ctx.service.stagePay.getStageLastestPays(ctx.stage.id);        yield calc.calculateAll(dealPay);        const bqwc = app._.find(dealPay, {ptype: PayConst.payType.wc});        assert(bqwc.tp === 26220);        const bqyf = app._.find(dealPay, {ptype: PayConst.payType.yf});        assert(bqyf.tp === 26220);    });});
 |