'use strict'; /** * * * @author Mai * @date 2020/4/17 * @version */ const { app, assert } = require('egg-mock/bootstrap'); const path = require('path'); let savePath; const mockData = {}; describe('test/app/service/rpt_gather_memory.test.js', () => { // 准备测试数据 before(function* () { const ctx = app.mockContext(); savePath = path.join(ctx.app.baseDir,'report_temp'); const postData = { account: '734406061@qq.com', project: 'T201711273363', project_password: 'mai654321', }; ctx.session = {}; const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2); assert(loginResult); mockData.session = ctx.session; }); // 台账数据 it('test getGatherStageBills - month', function* () { const ctx = app.mockContext(); const postData = { account: 'zengpeiwen', project: 'P1201', project_password: '123456', }; ctx.session = {}; const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2); // const select = { // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}], // type: 'month', // month: '2020-01', // }; // const select = { // tenders: [{tid: 2256}, {tid: 2257}], // type: 'ledger', // }; // const define = { // enable: true, // setting: JSON.stringify({ // title: '请选择汇总的标段', // type: 'month', // special: [ // {"title": "批复概算", "key": "gs"} // ] // }) // }; const select = { tenders: [{tid: 2659}], type: 'final', }; const define = { enable: true, setting: JSON.stringify({ title: '请选择汇总的标段', type: 'final', hasPre: true }) }; const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherStageBills([], define, select); yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_stage_bills.json')); // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis'); // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills}; // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, { // cDefine: { gather_select: select }, // tplDefine: {gather_select: define }, // }); // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json')); // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2); }); // 标段信息 it('test getGatherTenderInfo - month', function* () { const ctx = app.mockContext(mockData); // const select = { // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}], // type: 'month', // month: '2020-01', // }; const select = { tenders: [{tid: 2256}, {tid: 2257}], type: 'ledger', }; // const define = { // enable: true, // setting: JSON.stringify({ // title: '请选择汇总的标段', // type: 'month', // special: [ // {"title": "批复概算", "key": "gs"} // ] // }) // }; const define = { enable: true, setting: JSON.stringify({ title: '请选择汇总的标段', type: 'ledger', }) }; const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherTenderInfo([], define, select); yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_tender_info.json')); // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis'); // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills}; // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, { // cDefine: { gather_select: select }, // tplDefine: {gather_select: define }, // }); // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json')); // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2); }); // 标段信息 it('test getGatherDealPay - final', function* () { const ctx = app.mockContext(mockData); // const select = { // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}], // type: 'month', // month: '2020-01', // }; const select = { tenders: [{tid: 2256}, {tid: 2257}], type: 'final', }; // const define = { // enable: true, // setting: JSON.stringify({ // title: '请选择汇总的标段', // type: 'month', // special: [ // {"title": "批复概算", "key": "gs"} // ] // }) // }; const define = { enable: true, setting: JSON.stringify({ title: '请选择汇总的标段', type: 'final', }) }; const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherStagePay([], define, select); yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_pay.json')); // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis'); // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills}; // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, { // cDefine: { gather_select: select }, // tplDefine: {gather_select: define }, // }); // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json')); // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2); }); it('test getGatherDealBills - final', function* () { const ctx = app.mockContext(mockData); // const select = { // tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}], // type: 'month', // month: '2020-01', // }; const select = { tenders: [{tid: 2256}, {tid: 2257}], type: 'final', }; // const define = { // enable: true, // setting: JSON.stringify({ // title: '请选择汇总的标段', // type: 'month', // special: [ // {"title": "批复概算", "key": "gs"} // ] // }) // }; const define = { enable: true, setting: JSON.stringify({ title: '请选择汇总的标段', type: 'final', }) }; const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherDealBills([], define, select); yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_deal_pay.json')); // const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis'); // const reportData = {mem_gather_stage_bills: mem_gather_stage_bills}; // reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, { // cDefine: { gather_select: select }, // tplDefine: {gather_select: define }, // }); // yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json')); // assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2); }); });