docparse-scraper-nst
Version:
Node Zombie based scraper to scrape bills from the NStar (supplier code "NST)" website
56 lines (50 loc) • 1.46 kB
JavaScript
var inspect = require('eyespect').inspector();
var Browser = require('zombie');
var should = require('should');
var getBillDates = require('../lib/getBillDates');
var config = require('nconf');
var fs = require('fs');
var assert = require('assert');
var path = require('path');
var logger = require('./mockLogger');
describe('get bill dates', function () {
var html;
var bro = new Browser();
before(function (done) {
this.timeout('10s');
var filePath = path.join(__dirname, 'data/accountHomepage.html');
assert.ok(fs.existsSync(filePath), 'test html file not found at path: ' + filePath);
fs.readFile(filePath, 'utf8', function (err, reply) {
should.not.exist(err);
should.exist(reply);
html = reply;
bro.load(html, function (err, reply) {
should.not.exist(err);
done();
});
});
});
it('should give error when accountNumber field is not set', function (done) {
var data = {
bro: {}
};
getBillDates(data, function (err, reply) {
should.exist(err);
done();
});
});
it('should get data on account homepage correctly', function (done) {
this.slow(300);
var data = {
accountNumber: 'foo account number',
bro: bro
};
getBillDates(data, function (err, reply) {
should.not.exist(err);
should.exist(reply);
var desiredNum = 36;
desiredNum.should.eql(reply.length);
done();
});
});
});