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

Add fake behaviors to sandbox (#1815) #1842

Merged
merged 1 commit into from Jun 24, 2018

Conversation

nivsherf
Copy link
Contributor

Purpose (TL;DR) - mandatory

Fix for issue #1815 (No obvious way to reset fakes)

Solution - optional

Add fake and fake behaviors to sandbox.

How to verify - mandatory

  1. Check out this branch
  2. npm install
  3. npm test

Checklist for author

  • npm run lint passes
  • References to standard library functions are cached.

@coveralls
Copy link

coveralls commented Jun 15, 2018

Coverage Status

Coverage increased (+0.03%) to 85.333% when pulling 2a8a73c on nivsherf:sandboxFakeBehaviors into 8816e1a on sinonjs:master.

@@ -41,8 +41,8 @@ var hasFunctionNameSupport = noop.name === "noop";

describe("fake", function () {
describe("module", function () {
it("should return a unary Function named 'fake'", function () {
assert.equals(fake.length, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mroderick Was this important somehow?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a little thing I like to put into place, to make sure that the api doesn't change without anyone noticing. Unless fake suddenly accepts more than one argument, I'd like to keep it

Copy link
Member

@mantoni mantoni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Member

@mroderick mroderick left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you for you PR @nivsherf!

I only have a couple of comments


Object.keys(sinonFake).forEach(function (key) {
var fakeBehavior = sinonFake[key];
if (sinonFake.hasOwnProperty(key) && typeof fakeBehavior === "function") {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.keys return only keys directly upon the object, so there's no need to use hasOwnProperty.

@@ -41,8 +41,8 @@ var hasFunctionNameSupport = noop.name === "noop";

describe("fake", function () {
describe("module", function () {
it("should return a unary Function named 'fake'", function () {
assert.equals(fake.length, 1);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's just a little thing I like to put into place, to make sure that the api doesn't change without anyone noticing. Unless fake suddenly accepts more than one argument, I'd like to keep it

@nivsherf
Copy link
Contributor Author

Thanks for the feedback @mantoni and @mroderick!
As for the unary function test - I've now changed the sandbox.fake signature to match the original fake signature (i.e fake(f)), and added back the original unary test. Since f is not used in the sandbox proxy, I suppressed the no-unused-vars eslint rule for that line. I can see other ways to go about this but this seems to be the least obtrusive.

@mroderick mroderick added the semver:patch changes will cause a new patch version label Jun 24, 2018
@mroderick mroderick merged commit a3cf98f into sinonjs:master Jun 24, 2018
@mroderick
Copy link
Member

This has been published to NPM as sinon@6.0.1.

Thanks you ❤️

@nivsherf nivsherf deleted the sandboxFakeBehaviors branch June 24, 2018 18:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
semver:patch changes will cause a new patch version
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants