Skip to content

Commit

Permalink
adding actual tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
Vitaly Tomilov committed Mar 9, 2015
1 parent c71c9ee commit c292a70
Showing 1 changed file with 43 additions and 3 deletions.
46 changes: 43 additions & 3 deletions test/indexSpec.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,45 @@
describe("Test", function () {
it("test", function () {
// TODO : Test codes will be written
var pgpLib = require('../index')

describe("Library Loading", function () {
it("must be a function", function () {
expect(typeof(pgpLib)).toBe('function');
});
});

var pgp = pgpLib();

describe("Library Instance Check", function () {
it("must be a function", function () {
expect(typeof(pgp)).toBe('function');
});
it("must have pg property", function () {
expect(typeof(pgp.pg)).toBe('object');
});
it("must have as property", function () {
expect(typeof(pgp.as)).toBe('object');
});
it("must have end function", function () {
expect(typeof(pgp.end)).toBe('function');
});
});

describe("Query Result must be available", function () {
it("must be an object", function () {
expect(typeof(queryResult)).toBe('object');
});
it("must have all properties set correctly", function () {
expect(queryResult.one === 1 && queryResult.many === 2 && queryResult.none === 4 && queryResult.any === 6).toBe(true);
});
});

var db;

describe("Database Instantiation", function () {
it("must throw an error when no connection passed", function () {
expect(pgp).toThrow("Invalid 'cn' parameter passed.");
});
db = pgp("connection string");
it("must return a valid object", function () {
expect(typeof(db)).toBe('object');
});
});

0 comments on commit c292a70

Please sign in to comment.