-
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
8 changed files
with
259 additions
and
161 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
"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(".where", function () { | ||
var database = undefined, | ||
mockUsers = undefined; | ||
|
||
beforeEach(function () { | ||
database = new _libDatabaseJs2["default"](databaseConfig); | ||
mockUsers = [{ id: 1, name: "Bob" }]; | ||
}); | ||
|
||
it("should treat where equals to andWhere", function (done) { | ||
var name = "aName"; | ||
|
||
database.mock.select("*").from("users").where("created_at", ">", /.*/).where("name", name).results(mockUsers); | ||
|
||
database.select("*").from("users").where("created_at", ">", "2015-10-02 21:39:14").andWhere("name", name).results(function (error, rows) { | ||
if (error) { | ||
throw error; | ||
} | ||
rows.should.eql(mockUsers); | ||
done(); | ||
}); | ||
}); | ||
|
||
it("should use equals as the default operator", function (done) { | ||
database.mock.select("*").from("users").where("id", 1).results(mockUsers); | ||
|
||
database.select("*").from("users").where("id", "=", 1).results(function (error, rows) { | ||
if (error) { | ||
throw error; | ||
} | ||
rows.should.eql(mockUsers); | ||
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import Database from "../../lib/database.js"; | ||
|
||
const databaseConfig = require("../../../database.json").testing; | ||
|
||
describe(".where", () => { | ||
let database, | ||
mockUsers; | ||
|
||
beforeEach(() => { | ||
database = new Database(databaseConfig); | ||
mockUsers = [ | ||
{id: 1, name: "Bob"} | ||
]; | ||
}); | ||
|
||
it("should treat where equals to andWhere", done => { | ||
const name = "aName"; | ||
|
||
database.mock.select("*").from("users").where("created_at", ">", /.*/).where("name", name).results(mockUsers); | ||
|
||
database.select("*").from("users").where("created_at", ">", "2015-10-02 21:39:14").andWhere("name", name).results((error, rows) => { | ||
if (error) { throw error; } | ||
rows.should.eql(mockUsers); | ||
done(); | ||
}); | ||
}); | ||
|
||
it("should use equals as the default operator", done => { | ||
database.mock.select("*").from("users").where("id", 1).results(mockUsers); | ||
|
||
database.select("*").from("users").where("id", "=", 1).results((error, rows) => { | ||
if (error) { throw error; } | ||
rows.should.eql(mockUsers); | ||
done(); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.