This repository has been archived by the owner on Feb 8, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Increased coverage of connect method
- Loading branch information
1 parent
b009096
commit d7f874b
Showing
4 changed files
with
165 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,54 @@ | ||
var expect = require("chai").expect; | ||
var sinon = require("sinon"); | ||
|
||
var { HarperDB } = require("../index.js"); | ||
|
||
describe("HarperDB", () => { | ||
describe("HarperDB", function() { | ||
describe("#constructor()", () => { | ||
it("should return an instance of the HarperDB class", () => { | ||
it("should return an instance of the HarperDB class", function() { | ||
var db = new HarperDB(); | ||
expect(db).to.exist; | ||
expect(db).to.be.an.instanceof(HarperDB); | ||
}); | ||
}); | ||
describe("#connect()", () => { | ||
it("should throw error if not enough or invalid arguments are passed", () => { | ||
describe("#connect()", function() { | ||
it("should throw error if illegal arguments are passed", function() { | ||
var db = new HarperDB(); | ||
expect(function() { | ||
expect(arguments).to.be.arguments; | ||
db.connect(...arguments); | ||
}).to.throw(Error); | ||
expect(() => db.connect()).to.throw(Error); | ||
expect(() => db.connect(1)).to.throw(Error); | ||
expect(() => db.connect(1, 2)).to.throw(Error); | ||
|
||
expect(() => db.connect()).to.throw("Connect must be passed 3 arguments"); | ||
|
||
expect(() => db.connect("")).to.throw( | ||
"Connect must be passed 3 arguments" | ||
); | ||
|
||
expect(() => db.connect("", "")).to.throw( | ||
"Connect must be passed 3 arguments" | ||
); | ||
|
||
expect(() => db.connect(1, "", "")).to.throw( | ||
"connect() arguments must be strings" | ||
); | ||
|
||
expect(() => db.connect("", 1, "")).to.throw( | ||
"connect() arguments must be strings" | ||
); | ||
|
||
expect(() => db.connect("", "", 1)).to.throw( | ||
"connect() arguments must be strings" | ||
); | ||
}); | ||
|
||
it("should emit an error event on failed connect", function() { | ||
var db = new HarperDB(); | ||
var spy = sinon.spy(); | ||
db.event.on("error", spy); | ||
|
||
try { | ||
db.connect("x", "y", "z"); | ||
} catch (err) { | ||
expect(err).to.be.an("error"); | ||
expect(spy.called).to.be.true; | ||
} | ||
}); | ||
}); | ||
}); |