Skip to content

Commit

Permalink
Add test code of spy.matchingFakes
Browse files Browse the repository at this point in the history
  • Loading branch information
takasmiley committed Jun 28, 2017
1 parent cf3a34e commit 1661a0f
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions test/spy-test.js
Expand Up @@ -2507,5 +2507,44 @@ describe("spy", function () {
assert.equals(spy.length, 3);
});
});

describe(".matchingFakes", function () {
beforeEach(function () {
this.spy = createSpy();
});

it("is function", function () {
assert.isFunction(this.spy.matchingFakes);
});

it("returns an empty array by default", function () {
assert.equals(this.spy.matchingFakes([]), []);
assert.equals(this.spy.matchingFakes([1]), []);
assert.equals(this.spy.matchingFakes([1, 1]), []);
});

it("returns one matched fake", function () {
this.spy.withArgs(1);
this.spy.withArgs(2);

assert.equals(this.spy.matchingFakes([1]), [this.spy.withArgs(1)]);
assert.equals(this.spy.matchingFakes([2]), [this.spy.withArgs(2)]);
});

it("return some matched fake", function () {
this.spy.withArgs(1);
this.spy.withArgs(1, 1);
this.spy.withArgs(2);

assert.equals(this.spy.matchingFakes([]), []);
assert.equals(this.spy.matchingFakes([1]), [
this.spy.withArgs(1)
]);
assert.equals(this.spy.matchingFakes([1, 1]), [
this.spy.withArgs(1),
this.spy.withArgs(1, 1)
]);
});
});
});

0 comments on commit 1661a0f

Please sign in to comment.