Skip to content

Commit

Permalink
Use property of this, not variable
Browse files Browse the repository at this point in the history
  • Loading branch information
takasmiley authored and chrisbreiding committed Jul 28, 2017
1 parent 79f27e3 commit aa59517
Showing 1 changed file with 10 additions and 11 deletions.
21 changes: 10 additions & 11 deletions test/stub-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -111,34 +111,33 @@ describe("stub", function () {
describe("should work firstCall and lastCall", function () {
var testComponentA = function () { return { render: function () { return "test a"; } }; };
var testComponentB = function () { return { render: function () { return "test b"; } }; };
var stub;

beforeEach(function () {
var fakeComponent = function (variant) {
return createStub().returns({
render: createStub().returns("fake component " + variant)
});
};
stub = createStub().throws("Nothing set");
stub.withArgs(testComponentA).returns(fakeComponent("a"));
stub.withArgs(testComponentB).returns(fakeComponent("b"));
this.stub = createStub().throws("Nothing set");
this.stub.withArgs(testComponentA).returns(fakeComponent("a"));
this.stub.withArgs(testComponentB).returns(fakeComponent("b"));
});

it("returnValues", function () {
var config = { option: "a" };
var component = stub(testComponentA)(config);
var component = this.stub(testComponentA)(config);

assert.isTrue(stub.calledWith(testComponentA));
assert.isFalse(stub.calledWith(testComponentB));
assert.isTrue(this.stub.calledWith(testComponentA));
assert.isFalse(this.stub.calledWith(testComponentB));

assert.isFunction(component.render);
assert.equals(component.render(), "fake component a");

assert.isTrue(stub.withArgs(testComponentA).returnValues[0].calledWith(config));
assert.isTrue(stub.withArgs(testComponentA).getCall(0).returnValue.calledWith(config));
assert.isTrue(this.stub.withArgs(testComponentA).returnValues[0].calledWith(config));
assert.isTrue(this.stub.withArgs(testComponentA).getCall(0).returnValue.calledWith(config));

assert.isTrue(stub.withArgs(testComponentA).firstCall.returnValue.calledWith(config));
assert.isTrue(stub.withArgs(testComponentA).lastCall.returnValue.calledWith(config));
assert.isTrue(this.stub.withArgs(testComponentA).firstCall.returnValue.calledWith(config));
assert.isTrue(this.stub.withArgs(testComponentA).lastCall.returnValue.calledWith(config));
});
});

Expand Down

0 comments on commit aa59517

Please sign in to comment.