docparse-supplier-nge
Version:
process ngrid electric utility bill data for use in the docparse system
46 lines (44 loc) • 1.31 kB
JavaScript
var mongoose = require('mongoose');
var ObjectId = mongoose.Types.ObjectId;
var inspect = require('eyespect').inspector();
var should = require('should');
var path = require('path');
var check = require('../lib/checkScraperData');
describe('Check scraper data', function() {
var data;
beforeEach(function () {
data = {
supplierID: new ObjectId(),
customerID: new ObjectId(),
loginID: new ObjectId(),
accountNumber: 'foo account number',
billNumber: 'foo bill number',
billDate: '2011 03 19',
fromDate: '2011 01 19',
toDate: '2011 02 19',
supplierCode: 'NGE',
hash: 'foo hash',
textPages: ['foo page 1 text', 'bar page 2 text']
};
});
it('should give error for scraper data without a supplierID set', function(done) {
delete data.supplierID;
check(data, function (err) {
should.exist(err);
err.length.should.eql(1);
var error = err[0];
error.key.should.eql('supplierID');
done();
});
});
it('should give error for scraper data with empty textPages', function(done) {
data.textPages = [];
check(data, function (err) {
should.exist(err);
err.length.should.eql(1);
var error = err[0];
error.key.should.eql('textPages');
done();
});
});
});