deal_bills.test.js 807 B

12345678910111213141516171819202122232425262728
  1. 'use strict';
  2. /**
  3. *
  4. *
  5. * @author Mai
  6. * @date
  7. * @version
  8. */
  9. const { app, assert } = require('egg-mock/bootstrap');
  10. const excel = require('node-xlsx');
  11. describe('test/app/service/deal_bills.test.js', () => {
  12. it('test import Excel data', function* () {
  13. const ctx = app.mockContext();
  14. const file = app.baseDir + '/test/app/test_file/deal-upload-test.xls';
  15. const sheets = excel.parse(file), testTenderId = 3;
  16. const result = yield ctx.service.dealBills.importData(sheets[0], testTenderId);
  17. assert(result);
  18. const bills = yield ctx.service.dealBills.getAllDataByCondition({where: {tender_id: testTenderId}});
  19. assert(bills.length === 1);
  20. assert(bills[0].code === '101-1');
  21. assert(bills[0].tender_id === testTenderId);
  22. });
  23. });