simple-mock icon indicating copy to clipboard operation
simple-mock copied to clipboard

Getter/setter suport

Open almirfilho opened this issue 7 years ago • 1 comments

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!

almirfilho avatar Jan 12 '18 21:01 almirfilho

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

jupiter avatar Jan 21 '18 22:01 jupiter