NagRock / ts-mockito

Mocking library for TypeScript
MIT License
977 stars 93 forks source link

120: support set when mocking getters #176

Closed DW8Reaper closed 3 years ago

DW8Reaper commented 4 years ago

I'm pretty sure this wasn't the best way to do it but basically when you have a property on your object you basically cannot test anything that tries to set the property. To get it fixed I added a default implementation for the setter that registers a when for the property with the value just set.

On the plus side it lets you do set and kinda check if it worked by doing a get. On the minus side this is somewhat implicit. I cancelled my previous PR and created a new one with some updates and additional test coverage