mardi 6 mars 2018

Declaring getter property when building SpyObj using jasmine.createSpyObj utility?

Let's say I have a class:

class MyRealClass {
  get propOne() { return stuffFromTheServer; }
}

When testing, I want to achieve this functionality:

const mockClass = {
  get propOne() { return someStuff; }
}

jasmine.spyOnProperty(mockClass, 'propOne', 'get');

By doing something like this...

const spy = jasmine.createSpyObj('mockClass', [
  {methodName: 'propOne', accessType: 'get'}
]);

In other words, I want to build a SpyObj<MyRealClass> using the jasmine.createSpyObj and declare the getter properties as methods in the methodName array (the second parameter the the createSpyObj() method.

Is this possible?

Aucun commentaire:

Enregistrer un commentaire