drashland / rhum

A test double library
https://drash.land/rhum
MIT License
92 stars 6 forks source link

fix: Mocking a class with getters doesn't set default initialised value #148

Closed ebebbington closed 2 years ago

ebebbington commented 2 years ago

closes #145

problem was, the class was initialised with a default prop, so mock.Game should return it. Instead it was returning undefined:

Before

const mock = Mock(PlayersEngine).create()
mock.Game // undefined
mock.Game = "hello"
mock.game // "hello"

After

const mock = Mock(PlayersEngine).create()
mock.Game // "default game"
mock.Game = "hello"
mock.game // "hello"
crookse commented 2 years ago

LGTM except deno fmt doesn't like it