DEV Community

loading...

Discussion on: Testing an Effect using observer-spy

Collapse
shairez profile image
Shai Reznik

Great job Alfredo!

Few things I would try that might make your tests even shorter -

  1. You can use fakeTime and flush() to remove the need of using the TestScheduler.

  2. You can use the factory function subscribeSpyTo to subscribe and create the spy at the same time (and you can also auto-unsubscribe as well)

Let me know if it helps

Collapse
alfredoperez profile image
Alfredo Perez Author

Thank you, Shai!

I think it looks better, readable and fewer lines of code. Updated the article and repo.

I was not able to find subscribeSpyTo and used subscribeAndSpyOn instead.

Collapse
shairez profile image
Shai Reznik

Awesome Alfredo!

Try to update to the latest version (1.4.0) and you'll see subscribeSpyTo

Thread Thread
alfredoperez profile image
Alfredo Perez Author

Wooot!

I will update the repo and the article. Thanks!

Thread Thread
shairez profile image
Shai Reznik • Edited

Nice!

Pay attention that you've missed 1 subscribeAndSpyOn ... 😀

Thread Thread
alfredoperez profile image
Alfredo Perez Author

Thanks! it should be good now =)

Thread Thread
shairez profile image
Shai Reznik

Pair programming FTW! 💪😀