Skip to content
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

allow for creating testdoubles using interface only #400

Merged
merged 1 commit into from
Dec 31, 2018

Conversation

lgandecki
Copy link
Contributor

continuing from #399
@searls was right, the object function has all the necessary functionality built in. The only thing I had to tweak was this new type that allows for:

td.object<IMyInterface>(); 

but even with the current code testdouble actually allowed for mocking based on an interface, but with a bit of redundancy:

td.object<IMyInterface>("");

@wpannell you can use the second one already (with an argument of a string) for your training, with this merged in you will be able to remove the argument for a bit cleaner syntax.

@wpannell
Copy link

@lgandecki awesome

@searls
Copy link
Member

searls commented Dec 31, 2018

Yep, seems legit. @lgandecki since I'm not really a TS user, would you mind opening a follow-on PR that does a couple things?

  1. Documents this. I imagine a brief description in README and a docs/10-using-with-typescript.md file with examples or screenshots would really be great

  2. Add typings to other top-level td APIs that might be better typified. Seems odd only td.object would do it.

@searls searls merged commit bf27f90 into testdouble:master Dec 31, 2018
@lgandecki
Copy link
Contributor Author

Sure!
I'm off this week starting in a few hours, and I promised myself not to do anything programming-related... I will jump on it right away when I'm back.

Happy new year!

@searls
Copy link
Member

searls commented Dec 31, 2018

Landed in 3.9.2

@lgandecki
Copy link
Contributor Author

I've attempted something for 1. in #401 which to some degree also covers 2.
We could still make it so td.imitate<> works with its magic power, but it would require a little bit of hacking in the code itself, besides just changing the typings. I might give it a try at some point.

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

Successfully merging this pull request may close these issues.

None yet

3 participants