Skip to content
This repository has been archived by the owner on Apr 18, 2022. It is now read-only.

feat(spy): Adds argument support for function calls #29

Merged
merged 1 commit into from
Feb 8, 2022

Conversation

jhechtf
Copy link
Contributor

@jhechtf jhechtf commented Feb 7, 2022

Description

I was recently using this library in a small Deno project and found that the typing on function calls was a bit lacking and was causing some TS errors since I would pass a function that required multiple arguments, but the returned type only ever had 1 listed.

Contents

I've upgraded the overload responsible for function call spying to include some defaults to the values, as well as to more strongly type the returned function. Similarly, I've added a test to specifically check that returned noted function signature carries over to the spied counterpart, e.g. a function of type (a: number: b: string) => number should have an equivalent signature when run through the spy() function.

Test Results

Full test results can be included if needed, but I believe the summary should hopefully be enough.

test result: ok. 67 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out (1s)

@jhechtf jhechtf force-pushed the feat/add-types-for-function-returns branch from bb162f2 to 24e7876 Compare February 7, 2022 18:39
Copy link
Member

@KyleJune KyleJune left a comment

Choose a reason for hiding this comment

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

This looks like a good feature. I'll include this change in version 0.13.0 and publish it after I merge this and update dependencies.

@KyleJune KyleJune merged commit 4273105 into udibo:main Feb 8, 2022
@KyleJune
Copy link
Member

I've refactored mock completely to add much better types in 0.14.0. Thanks for this PR, it gave me the idea to update all of the functions to have good types.

@jhechtf
Copy link
Contributor Author

jhechtf commented Mar 20, 2022 via email

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants