| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253 | 'use strict';/** * * * @author Mai * @date * @version */const { app, assert } = require('egg-mock/bootstrap');const mockData = {};const path = require('path');describe('test/app/service/report_memory.test.js', () => {    // 准备测试数据    before(function* () {        const ctx = app.mockContext();        // 模拟登录session        const postData = {            account: 'fuqingqing',            project: 'P0505',            project_password: '123456',        };        // const postData = {        //     account: 'chente',        //     project: 'T201711273363',        //     project_password: '123456',        // };        ctx.session = {};        const loginResult = yield ctx.service.projectAccount.accountLogin(postData, 2);        assert(loginResult);        mockData.session = ctx.session;    });    // 数据    it('test getReportData', function* () {        const ctx = app.mockContext(mockData);        // test12 - 第6期        const stage = yield ctx.service.stage.getDataByCondition({tid: 12, order: 6});        const params = {            tender_id: stage.tid,            stage_id: stage.id,        };        const filters = ['change', 'change_audit_list'];        const result = yield ctx.service.report.getReportData(ctx, params, filters);        const savePath = path.join(ctx.app.baseDir, 'report_temp');        yield ctx.helper.recursiveMkdirSync(savePath);        for (const table in result) {            yield ctx.helper.saveBufferFile(JSON.stringify(result[table],"","\t"), path.join(savePath, table + '.json'));        }    });});
 |