Skip to content

Commit

Permalink
Merge pull request #1436 from sinonjs/feature-detect-name-property
Browse files Browse the repository at this point in the history
Feature detect function name property in issue 950
  • Loading branch information
mroderick committed May 29, 2017
2 parents e0c75bd + 65d3d7b commit 9e3eac3
Showing 1 changed file with 20 additions and 17 deletions.
37 changes: 20 additions & 17 deletions test/issues/issues-test.js
Expand Up @@ -123,30 +123,33 @@ describe("issues", function () {
});

describe("#950 - first execution of a spy as a method renames that spy", function () {
it("should not rename spies", function () {
var expectedName = "proxy";
function bob() {}

function bob() {}
var spy = sinon.spy(bob);
// IE 11 does not support the function name property
if (bob.name) {
it("should not rename spies", function () {
var expectedName = "proxy";
var spy = sinon.spy(bob);

assert.equals(spy.name, expectedName);
assert.equals(spy.name, expectedName);

var obj = { methodName: spy };
assert.equals(spy.name, expectedName);
var obj = { methodName: spy };
assert.equals(spy.name, expectedName);

spy();
assert.equals(spy.name, expectedName);
spy();
assert.equals(spy.name, expectedName);

obj.methodName.call(null);
assert.equals(spy.name, expectedName);
obj.methodName.call(null);
assert.equals(spy.name, expectedName);

obj.methodName();
assert.equals(spy.name, expectedName);
obj.methodName();
assert.equals(spy.name, expectedName);

obj.otherProp = spy;
obj.otherProp();
assert.equals(spy.name, expectedName);
});
obj.otherProp = spy;
obj.otherProp();
assert.equals(spy.name, expectedName);
});
}
});

describe("#1026", function () {
Expand Down

0 comments on commit 9e3eac3

Please sign in to comment.