Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Deleted incorrect issue] #1718

Closed
roneyrao opened this issue Mar 3, 2018 · 2 comments
Closed

[Deleted incorrect issue] #1718

roneyrao opened this issue Mar 3, 2018 · 2 comments

Comments

@roneyrao
Copy link

roneyrao commented Mar 3, 2018

We understand you have a problem and are in a hurry, but please provide us with some info to make it much more likely for your issue to be understood, worked on and resolved quickly.

  • Sinon version : please verify that the bug exists in the latest Sinon release 4.4.2
  • Environment : Linux version 4.10.0-43-generic (buildd@lgw01-amd64-037) (gcc version 6.3.0 20170406 (Ubuntu 6.3.0-12ubuntu2)
  • Example URL :
  • Other libraries you are using:

What did you expect to happen?

  var obj = {};
  function Cls() {
    return obj;
  }
  expect(new Cls()).equal(obj); // true

  var ClassSpy = sinon.spy(Cls);
  expect(new ClsSpy()).equal(obj); // false, expect true

What actually happens
It does not respect the rule that when a function returns an object, this object should become the instance of it when called with new as a constructor.

How to reproduce

Describe with code how to reproduce the faulty behaviour,
or link to code on JSBin or similar

Really long code sample or stacktrace
If you need to provide a dump of a stack trace or
other lengthy material, such as 80 lines of example code,
please stuff it in a `<details>` tag such as this
to make the issue more readable. Thanks.
@mantoni
Copy link
Member

mantoni commented Mar 3, 2018

Thanks for filing. I think #1683 is somewhat related.

@mantoni
Copy link
Member

mantoni commented Mar 3, 2018

Same as #1676

@roneyrao roneyrao changed the title Fail when constructor returns an object as instance [Deleted] Mar 9, 2018
@roneyrao roneyrao closed this as completed Mar 9, 2018
@roneyrao roneyrao changed the title [Deleted] [Deleted incorrect issue] Mar 9, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants