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
improve-stubs-doc.md #2152
improve-stubs-doc.md #2152
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi, thanks for you contribution! While I can sympathize with the intent, unfortunately the execution doesn't go that well with the new work that has gone into making runnable examples. See all the work done on #2122 for the spies docs.
If there should be changes to the example code in the documentation, then the changes should be made so that they are actually runnable. The new example you posted would not pass this, as ./emailService
is not an actual module.
Provide very simple code to test as an example, instead of external library's (PubSub) code
I don't see how it's actually easier? The interface of PubSub is already pretty simple, so any consumer could be made pretty simple as well. I think adjusting your example might end up being just as simple.
docs/release-source/release/stubs.md
Outdated
// VERIFY | ||
expect(result).toBe("Error occurred in email client!"); | ||
// TEARDOWN | ||
sendStub.restore(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As tests have a tendency to fail, it's better to have restore steps that will run irrespective of the failure status. This is better left to a afterEach
hook.
docs/release-source/release/stubs.md
Outdated
it('should handle EmailClientError when emailService throws', function() { | ||
|
||
// SETUP | ||
let sendStub = sinon.stub(emailService, 'send').throws('EmailClientError'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Avoid let
and other ES2015+ syntax in the examples. We try to have all produced be ES5.1 compatible.
Is there something I can do to get the train back on its tracks? |
Hello, sorry for not giving a reply thus far. Okay, I understand your points, and probably there's no need to remove the use of PubSub (I didn't really know what PubSub was about). I plan to try implementing runnable code this weekend, so I'll keep you posted. |
One shouldn't really need to know anything about the implementation of pubsub either. It's just an example of a very common pattern used practically everywhere: Publish/Subscribe (which is more or less the same as the Observer Pattern). As it usually just deals with two methods; |
I have replaced almost all the examples to be runnable in my latest change. There are 2 examples (yieldsTo, callArg) for which I had trouble making tests that would pass, perhaps due to me not fully understanding the two functions. |
Wow, this seems great. I will need to check it out to understand what (if anything) is wrong with the 2 examples you mention, but in any case, this is a huge improvement. |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions. |
Ooh, bad me. I have forgotten about this ... |
I have looked into this and there was a test I could not get passing, sandbox.spy(jQuery, 'getJSON');
sandbox.spy(jQuery, 'ajax');
//sandbox.spy(jQuery); I will look some more into it. EDIT: the example was at fault. |
This is not abandoned, btw. I am actively working on a fork of this branch to get everything working, but I am struggling with a last test, as |
Included this in #2239 (leaving your commit intact!), so when/if that gets merged, then so will this :) |
Thanks for all the work, @andrewdroz! I had some additions as you can see in the PR that built upon this, but this should be live as soon as the next release is published. |
#2062
Purpose (TL;DR) - mandatory
Improvement to stubs doc
How to verify - mandatory
N.A. because no code change
Checklist for author
npm run lint
passes