-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
11 changed files
with
97 additions
and
20 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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
"use strict"; | ||
|
||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
|
||
var _libDatabaseJs = require("../../lib/database.js"); | ||
|
||
var _libDatabaseJs2 = _interopRequireDefault(_libDatabaseJs); | ||
|
||
var databaseConfig = require("../../../database.json").testing; | ||
|
||
describe(".mock.results(mockResults)", function () { | ||
var database = undefined; | ||
|
||
beforeEach(function () { | ||
database = new _libDatabaseJs2["default"](databaseConfig); | ||
}); | ||
|
||
it("should return the mock query", function () { | ||
var mockQuery = database.mock; | ||
mockQuery.select("*").from("users").should.equal(mockQuery); | ||
}); | ||
|
||
it("should increment the call count when subsequent matching queries are executed", function (done) { | ||
var user = { | ||
id: "cigyn1qip0000nxz84cv3bwu6", | ||
name: "Bob" | ||
}; | ||
|
||
var mockQuery = database.mock.select("*").from("users").results(user); | ||
|
||
database.select("*").from("users").results(function () { | ||
mockQuery.called.should.be["true"]; | ||
done(); | ||
}); | ||
}); | ||
}); |
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
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
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 |
---|---|---|
@@ -0,0 +1,36 @@ | ||
import Database from "../../lib/database.js"; | ||
|
||
const databaseConfig = require("../../../database.json").testing; | ||
|
||
describe(".mock.results(mockResults)", () => { | ||
let database; | ||
|
||
beforeEach(() => { | ||
database = new Database(databaseConfig); | ||
}); | ||
|
||
it("should return the mock query", () => { | ||
const mockQuery = database.mock; | ||
mockQuery.select("*").from("users").should.equal(mockQuery); | ||
}); | ||
|
||
it("should increment the call count when subsequent matching queries are executed", done => { | ||
const user = { | ||
id: "cigyn1qip0000nxz84cv3bwu6", | ||
name: "Bob" | ||
}; | ||
|
||
const mockQuery = database.mock | ||
.select("*") | ||
.from("users") | ||
.results(user); | ||
|
||
database | ||
.select("*") | ||
.from("users") | ||
.results(() => { | ||
mockQuery.called.should.be.true; | ||
done(); | ||
}); | ||
}); | ||
}); |
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,16 +1,16 @@ | ||
import Database from "../../lib/database.js"; | ||
import MockQuery from "../../lib/mockQuery.js"; | ||
|
||
const databaseConfig = require("../../../database.json").testing; | ||
|
||
describe(".mock", () => { | ||
|
||
let database; | ||
|
||
beforeEach(() => { | ||
database = new Database(databaseConfig); | ||
}); | ||
|
||
it("should return an instance of itself for chaining", () => { | ||
database.mock.should.eql(database); | ||
it("should return an instance of MockQuery", () => { | ||
database.mock.should.be.instanceOf(MockQuery); | ||
}); | ||
}); |
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