Skip to content

Commit

Permalink
Feature detect function name property in issue 950
Browse files Browse the repository at this point in the history
IE 11 does not support the name property on functions. With this change
the test case for issue 950 is only executed if the name property is
supported.
  • Loading branch information
mantoni committed May 29, 2017
1 parent e0c75bd commit 65d3d7b
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 65d3d7b

Please sign in to comment.