docparse-supplier-nge
Version:
process ngrid electric utility bill data for use in the docparse system
53 lines (51 loc) • 1.25 kB
JavaScript
var should = require('should');
var inspect = require('eyespect').inspector();
var calc = require('../lib/parse/calculateToPay');
describe('calculate to pay', function () {
this.slow('1s');
var data;
beforeEach(function () {
data = {
costOtherSupply: {
total: '0',
costs: []
},
costSupply: '1.10',
costDelivery: '2.10',
costOther: {
total: '1.00',
costs: [
{
description: 'Random other cost 1',
value: '0.50'
},
{
description: 'Random other cost 2',
value: '0.50'
}
]
}
};
});
it('should give error when costOtherSupply exists', function (done) {
data.costOtherSupply.total = '1.00';
data.costOtherSupply.costs =[{
description: 'Random other supply cost',
value: '0.50'
}];
var actualTotal = '4.70';
calc(data, function (err, reply) {
should.exist(err);
done();
});
});
it('should calculate cost supply', function (done) {
calc(data, function (err, reply) {
should.not.exist(err);
should.exist(reply);
var actualTotal = '4.20';
actualTotal.should.eql(reply);
done();
});
});
});