UNPKG

docparse-supplier-nge

Version:

process ngrid electric utility bill data for use in the docparse system

63 lines (56 loc) 1.46 kB
var inspect = require('eyespect').inspector(); var should = require('should'); var processPage = require('../lib/upload/processPage'); describe('process page', function () { var pageText = 'foo page 1 text'; it('should find bill',function (done) { var bill = { toObject: function () { return this; } }; var handleError = function (data, cb) { cb(null, bill); }; var findBillFromPageText = function (data, cb) { cb(null, {bill: bill}); }; var data = { accountNumbers: ['foo', 'bar'], upload: { text_pages: [pageText] }, page: pageText, findBillFromPageText: findBillFromPageText }; processPage(data, function (err, reply) { should.not.exist(err); done(); }); }); it('should not find bill when bill numbers do not exist', function (done) { var bill = {}; var handleError = function (data, cb) { cb(null, bill); }; var findBillFromPageText = function (data, cb) { cb(null, bill); }; var data = { accountNumbers: ['foo', 'bar'], upload: { text_pages: [pageText] }, page: pageText, handleError: handleError, findBillFromPageText: findBillFromPageText }; data.findBillFromPageText = function (data, cb) { cb(null, {}); }; processPage(data, function (err, reply) { should.not.exist(err); done(); }); }); });