rpt_gather_memory.test.js 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date 2020/4/17
  7. * @version
  8. */
  9. const { app, assert } = require('egg-mock/bootstrap');
  10. const path = require('path');
  11. let savePath;
  12. const mockData = {};
  13. describe('test/app/service/rpt_gather_memory.test.js', () => {
  14. // 准备测试数据
  15. before(function* () {
  16. const ctx = app.mockContext();
  17. savePath = path.join(ctx.app.baseDir,'report_temp');
  18. const postData = {
  19. account: '734406061@qq.com',
  20. project: 'T201711273363',
  21. project_password: 'mai654321',
  22. };
  23. ctx.session = {};
  24. const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);
  25. assert(loginResult);
  26. mockData.session = ctx.session;
  27. });
  28. // 期部位明细数据
  29. it('test getGatherStageBills - month', function* () {
  30. const ctx = app.mockContext(mockData);
  31. const select = {
  32. tenders: [{tid: 2256}, {tid: 2257}, {tid: 2258, gs: true}],
  33. type: 'month',
  34. month: '2020-01',
  35. };
  36. const define = {
  37. enable: true,
  38. setting: {
  39. title: '请选择汇总的标段',
  40. type: 'month',
  41. special: [
  42. {"title": "批复概算", "key": "gs"}
  43. ]
  44. }
  45. };
  46. const mem_gather_stage_bills = yield ctx.service.rptGatherMemory.getGatherStageBills([], define, select);
  47. yield ctx.helper.saveBufferFile(JSON.stringify(mem_gather_stage_bills, "", "\t"), path.join(savePath, 'mem_gather_stage_bills.json'));
  48. const reportDataAnalysis = require('../../../app/lib/rpt_data_analysis');
  49. // 配合部位明细
  50. const reportData = {mem_gather_stage_bills: mem_gather_stage_bills};
  51. reportDataAnalysis.analysisObj.gatherSelectConverse.fun(ctx, reportData, [], {table: ["mem_gather_stage_bills"]}, {
  52. cDefine: { gather_select: select },
  53. tplDefine: {gather_select: define },
  54. });
  55. yield ctx.helper.saveBufferFile(JSON.stringify(reportData, "", "\t"), path.join(savePath, 'mem_gather_stage_bills_coverse.json'));
  56. assert(reportData.mem_gather_stage_bills.length === mem_gather_stage_bills.length * 2);
  57. });
  58. });