jupiter / simple-mock

Super simple stubs and spies with 1-step sandbox restore
MIT License
87 stars 12 forks source link

Getter/setter suport #28

Open almirfilho opened 6 years ago

almirfilho commented 6 years ago

Is there any plans to support getters and setters mocking as well? Right now it doesn't seem to work at all.

src:

class Device {
  static model = 'Nexus';

  static get isIphoneX(){
    return this.model === 'iPhone X';
  }
}

test:

const mock1 = simple.mock(Device, 'isIphoneX', true);
console.log(Device.isIphoneX); // => false
console.log(mock1.callCount); // => undefined

const mock2 = simple.mock(Device, 'isIphoneX').returnWith(true);
console.log(Device.isIphoneX); // => false
console.log(mock2.callCount); // => undefined

Thank you!

jupiter commented 6 years ago

This would be a good addition, especially since getters and setters seems to be used more frequently with ES6 class syntax.