Repository navigation
docs: add an API reference to the README - #59
Open
shaurya703 wants to merge 1 commit into
Open
shaurya703 wants to merge 1 commit into
shaurya703 wants to merge 1 commit into
Conversation
Closes tinylibs#40 The README showed usage but never documented the surface, so there was nothing to point at for what a given export or property does. This adds a reference covering every symbol on the checklist in tinylibs#40: - spy, spyOn, restoreAll - shared spy properties: called, callCount, calls, results, resolves, returns, length, impl, reset, nextResult, nextError - spyOn-only methods: getOriginal, willCall, restore, and the Symbol.dispose/`using` form - the internal exports vitest builds on: spies, createInternalSpy, internalSpyOn, getInternalState It also documents behaviour that was not written down anywhere: the argument errors each guard throws, that `spyOn` resolves along the prototype chain, that a mock argument is optional, that `spy()` spies are never added to `spies`, and that the nextResult/nextError queue is FIFO and consumed once per entry. Four existing examples were wrong and are corrected: - `results` and `resolves` hold tuples, so they print as [['ok', ...]], not ['ok', ...] (three places) - the last restore example called `obj.restore()`; the spy is bound to `spy`, so it is `spy.restore()` Every example was executed against the build rather than written from reading the source; all 18 assertions pass, including the `using` block. 52 tests still pass and prettier is clean β the file was prettier-clean before this change and the only deletions in the diff are the four corrections above.
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #40
The README showed usage but never documented the surface, so there was nothing to point at for what a given export or property does. This adds a reference covering every symbol on the checklist in #40:
spy,spyOn,restoreAllcalled,callCount,calls,results,resolves,returns,length,impl,reset,nextResult,nextErrorspyOn-only methods βgetOriginal,willCall,restore, and theSymbol.dispose/usingformspies,createInternalSpy,internalSpyOn,getInternalStateIt also writes down behaviour that wasn't documented anywhere: the argument errors each guard throws, that
spyOnresolves along the prototype chain, that themockargument is optional, thatspy()spies are never added tospies, and that thenextResult/nextErrorqueue is FIFO and consumed once per entry.Corrections
Four existing examples were wrong:
resultsandresolveshold tuples, so they print as[['ok', ...]], not['ok', ...]β three placesrestoreexample calledobj.restore(), but the spy is bound tospy, so it'sspy.restore()Verification
Every example was executed against the build rather than written from reading the source β all 18 assertions pass, including the
usingblock.52 tests still pass. The file was prettier-clean before this change and is after it, and the only deletions in the diff are the four corrections above.