template_node.test.js 730 B

123456789101112131415161718192021222324252627
  1. 'use strict';
  2. /**
  3. * 指标节点业务逻辑 单元测试
  4. *
  5. * @author Mai
  6. * @data 2018/4/20
  7. * @version
  8. */
  9. const { app, assert } = require('egg-mock/bootstrap');
  10. // excel解析
  11. const excel = require('node-xlsx');
  12. describe('test/app/service/template_node.test.js', () => {
  13. it('_parseSheetData test', function () {
  14. const ctx = app.mockContext();
  15. const fileName = app.baseDir + '/test/app/service/test.xls';
  16. const sheets = excel.parse(fileName);
  17. const nodes = [], indexes = [];
  18. for (const sheet of sheets) {
  19. ctx.service.templateNode._parseSheetData(sheet, nodes, indexes);
  20. }
  21. assert(nodes.length === 5);
  22. assert(indexes.length === 42);
  23. });
  24. });