UNPKG

docparse-dumpinvoices

Version:

takes a list of couchdb invoice ids and exports the data contained within those invoices to an Excel spreadsheet

47 lines (44 loc) 1.52 kB
var should = require('should') var path = require('path') var fs = require('fs') var assert = require('assert') var inspect = require('eyespect').inspector() var exec = require('child_process').exec var getTemplatePath = require('../getTemplatePath') describe('template.xls', function() { var template_path it('should find template file', function(done) { template_path = getTemplatePath() assert.ok(fs.existsSync(template_path, 'template.xls output spreadsheet not found')) done() }) it('should have correct sheet names and indices', function(done) { this.timeout(3*1000) this.slow(1*1000) var cmd = 'python '+path.join(__dirname,'../get_sheets.py')+' "'+template_path+'"' var child = exec(cmd, function (err, stdout, stderr) { should.not.exist(err) stderr.length.should.equal(0) should.exist(stdout) stdout.length.should.be.above(0) var data = JSON.parse(stdout) /** * data look like * [ { name: 'Electricity- Utility T&D', index: 0 }, { name: 'Electricity- Supply', index: 1 }, { name: 'Natural Gas- Utility T&D', index: 2 }, { name: 'Natural Gas- Supply', index: 3 }, { name: 'Water', index: 4 } ] */ // check the names data[0].name.should.equal('Electricity NGrid or Nstar') data[1].name.should.equal('EL-Supplier') data[2].name.should.equal('Gas Ngrid or Nstar') data[3].name.should.equal('NG-Supplier-Hess') done() }) }) })