Repository navigation
fix: nextResult and nextError return the spy, so they chain - #61
Open
shaurya703 wants to merge 1 commit into
Open
shaurya703 wants to merge 1 commit into
shaurya703 wants to merge 1 commit into
Conversation
`Spy` declares both as returning `this`, but `populateSpy` returned the
internal state, which has neither method. The chain the types promise
compiled and then threw:
s.nextResult('a').nextResult('b')
// TypeError: s.nextResult(...).nextResult is not a function
Return the spy, as `willCall` already does, and pin it with a test that
chains through both.
Closes tinylibs#60
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 #60
SpydeclaresnextResultandnextErroras returningthis, butpopulateSpyreturned the internal state object, which has neither method. So the chain the types allow compiles and then throws at runtime:This returns the spy from both, the same way
willCallininternalSpyOnalready does. The two existing call sites in the tests call them as separate statements, so nothing else changes.Test
One new test pins the identity (
nextResult(...)andnextError(...)bothtoBethe spy) and a mixed chainnextResult(2).nextError(err).nextResult(3), then drains the queue in order. It fails onmainwithexpected { reset: [Function reset], …(7) } to be [Function spy]and passes with the change.pnpm build && pnpm test: 53/53.tsc --noEmitclean.