-
-
Notifications
You must be signed in to change notification settings - Fork 770
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
Use runkit snippets in fake documentation #2381
Conversation
@@ -4,7 +4,7 @@ const referee = require("@sinonjs/referee"); | |||
const assert = referee.assert; | |||
|
|||
describe("FakeTest", function () { | |||
it("should have working lastArg property", function () { |
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.
this was leftover
|
||
#### `sinon.fake.yieldsAsync([value1, ..., valueN]);` | ||
|
||
Similar to `yields`, `yieldsAsync` also returns a function that when invoked, the function expects the last argument to be a callback and invokes that callback with the same previously given values. However, the returned function invokes that callback asynchronously rather than immediately, i.e. in the next event loop. | ||
|
||
Compare the output of the code example below with the output of the code example above for `yields` to see the difference. |
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.
no more output comparison, so the change is needed
|
||
#### `f.firstArg` | ||
|
||
This property is a convenient way to get a reference to the first argument passed in the last call to the fake. | ||
The same convenience has been added to [spy calls](../spy-call#spycallfirstarg). |
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.
runkit samples have the spy call part indicated with a comment
Perfect! The only thing that is a bit of a shame with RunKit is that you don't know that it is loading until it has finished loading. And if RunKit is down for some reason, we have no examples to show. That's why I would like to replace the <div data-example-id="fakes-11-lastArg"></div> with something like @includeExample("fakes-11-lastArg") that would produce something like <div data-example-id="fakes-11-lastArg">
<!-- some syntax colouring tag here -->
require("@fatso83/mini-mocha").install();
const sinon = require("sinon");
const referee = require("@sinonjs/referee");
const assert = referee.assert;
describe("FakeTest", function () {
it("should have working lastArg", function () {
const f = sinon.fake();
const date1 = new Date();
const date2 = new Date();
f(1, 2, date1);
f(1, 2, date2);
assert.isTrue(f.lastArg === date2);
// spy call methods:
assert.isTrue(f.getCall(0).lastArg === date1);
assert.isTrue(f.getCall(1).lastArg === date2);
assert.isTrue(f.lastCall.lastArg === date2);
});
});
</div> That would make it show working examples even if javascript should crash or the RunKit service being down. |
P.S. That is a different PR, btw 😄 |
So |
Exactly! TBH, it's probably not worth the (not so big) effort of creating a Liquid Tag (a Tag is the name the Liquid templating system calls what you called a macro). All I was thinking about was something like just using The least effort way (without creating a Tag) is probably just doing something manual like
As you see, there is some repetition, making it easy to make mistakes, and it does not solve how to add syntax highlighing for the fallback, but maybe it's good enough for a fallback? |
Purpose (TL;DR) - mandatory
In #2360, I forgot to replace snippets with runkit samples. This pr adds runkit samples to fakes.md and makes small changes to the fakes.md required due to using runkit examples
How to verify - mandatory
_releases/latest
and copyrelease-source/release
to_releases
folder with the namelatest
Checklist for author
npm run lint
passes(only docs change is done, and no linting error in docs folder. there are some errors inscripts
folder but they are unrelated)cc @fatso83