UNPKG

ngrid-electric-login

Version:

Login to the NGrid Electric website using curl

54 lines (51 loc) 1.39 kB
var path = require('path') var rewire = require('rewire') var should = require('should'); var index = require('../index') describe('Wiring', function () { var data beforeEach(function () { data = { username: 'foo', password: 'bar' } }) it('should give error if username is not set', function (done) { delete data.username index(data, function (err, reply) { should.exist(err) err.error[0].key.should.eql('username') done() }) }) it('should give error if password is not set', function (done) { delete data.password index(data, function (err, reply) { should.exist(err) err.error[0].key.should.eql('password') done() }) }) it('should be wired up correctly', function (done) { var cookiePath = path.join(__dirname, 'data/sampleCookie.txt') var index = rewire('../index') index.__set__('getSignInPageData', function(cb) { var output = { viewState: 'fooViewState', eventValidation: 'barEventValidation' } cb(null, output) }) index.__set__('submitLogin', function(data, cb) { cb(null, cookiePath) }) index.__set__('validateAuthenticatedCookieData', function(cookieData) { return true }) index(data, function (err, reply) { should.not.exist(err) reply.should.eql(cookiePath) done() }) }) })