Skip to content

Commit

Permalink
mockQuery.calls now increments
Browse files Browse the repository at this point in the history
  • Loading branch information
dcrockwell committed Apr 25, 2016
1 parent 5d4c64c commit fb0aab8
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 2 deletions.
2 changes: 1 addition & 1 deletion es5/lib/query.js
Expand Up @@ -386,7 +386,7 @@ var Query = (function () {
}, {
key: "call",
get: function get() {
(0, _incognito2["default"])(this).calls += 1;
(0, _incognito2["default"])(this).calls = (0, _incognito2["default"])(this).calls + 1;
}
}, {
key: "delete",
Expand Down
18 changes: 18 additions & 0 deletions es5/spec/database/mock.results.spec.js
Expand Up @@ -33,4 +33,22 @@ describe(".mock.results(mockResults)", function () {
done();
});
});

it("should increment the call count more than once", function (done) {
var user = {
id: "cigyn1qip0000nxz84cv3bwu6",
name: "Bob"
};

var mockQuery = database.mock.select("*").from("users").results(user);

var query = database.select("*").from("users");

query.results(function () {
query.results(function () {
mockQuery.calls.should.eql(2);
done();
});
});
});
});
2 changes: 1 addition & 1 deletion es6/lib/query.js
Expand Up @@ -22,7 +22,7 @@ export default class Query {
}

get call() {
privateData(this).calls += 1;
privateData(this).calls = privateData(this).calls + 1;
}

select(...columns) {
Expand Down
21 changes: 21 additions & 0 deletions es6/spec/database/mock.results.spec.js
Expand Up @@ -33,4 +33,25 @@ describe(".mock.results(mockResults)", () => {
done();
});
});

it("should increment the call count more than once", done => {
const user = {
id: "cigyn1qip0000nxz84cv3bwu6",
name: "Bob"
};

let mockQuery = database.mock
.select("*")
.from("users")
.results(user);

const query = database.select("*").from("users");

query.results(() => {
query.results(() => {
mockQuery.calls.should.eql(2);
done();
});
});
});
});

0 comments on commit fb0aab8

Please sign in to comment.