UNPKG

node-jdbc-api

Version:

52 lines (45 loc) 1.35 kB
"use strict"; var expect = require('chai').expect; var JDBC = require('../index.js'); describe('JDBC connector', function(){ var config; var host; var validUsername; var validPassword; beforeEach(function(){ config = { host: host, username: validUsername, password: validPassword }; }); it('should not instantiate with an invalid host', function(){ expect(function (){ new JDBC({ host: 1 }); }).to.throw(Error, '\'host\' property is missing or invalid.'); }); it('should not instantiate with an invalid config', function(){ expect(function (){ new JDBC(); }).to.throw(Error, '\'config\' argument must be an object.'); }); it('should instantiate correctly with valid config and url', function(){ expect(function (){ new JDBC({ host: "somehost" }); }).to.not.throw(Error); }); it('should be able to create a new user with valid credentials', function(done){ var d = new JDBC(config); d.query({ query:"exec sp_help" }, function(err, res){ expect(err).to.be.null; expect(res).not.to.be.null; done(); }); }); });