12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- /**
- * Created by Tony on 2017/3/17.
- */
- var test = require('tape');
- var mongoose = require('mongoose');
- var JV = require('../../../modules/reports/rpt_component/Jpc_ValueDefine');
- var Template = require('../../../modules/reports/models/rpt_template');
- var TemplateData = require('../../../modules/reports/models/rpt_temp_data');
- var JpcEx = require('../../../modules/reports/rpt_component/JpcEx');
- var rptUtil = require("../../../modules/reports/util/rpt_util");
- test('test get report pages function: ', function (t) {
- rptUtil.setReportDefaultCache();
- t.pass('just pass for cache setup!');
- t.end();
- });
- test('test get report pages function: ', function (t) {
- var grp_id = "SC";
- var tpl_id = "07_1";
- var pageSize = "A4";
- var rptTpl = null, tplData = null;
- Template.getPromise(grp_id, tpl_id).then(function(rst) {
- //console.log(rst);
- rptTpl = rst;
- console.log(rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE]);
- t.equal(rptTpl != null, true);
- return TemplateData.getPromise(tpl_id);
- }).then(function(rst){
- //console.log(rst);
- tplData = rst;
- t.equal(tplData != null, true);
- if (tplData) {
- var printCom = JpcEx.createNew();
- rptTpl[JV.NODE_MAIN_INFO][JV.NODE_PAGE_INFO][JV.PROP_PAGE_SIZE] = pageSize;
- var defProperties = rptUtil.getReportDefaultCache();
- printCom.initialize(rptTpl);
- printCom.analyzeData(rptTpl, tplData, defProperties);
- var maxPages = printCom.totalPages;
- var pageRst = printCom.outputAsSimpleJSONPageArray(rptTpl, tplData, 1, maxPages, defProperties);
- t.equal(pageRst != null, true);
- }
- t.end();
- }).catch(function (err) {
- console.log("err: " + err);
- t.end();
- })
- });
- test('finish', function (t) {
- mongoose.disconnect();
- t.pass('closing db connection');
- t.end();
- });
|