Created
September 15, 2017 06:44
-
-
Save SeanSobey/524121586142ee29d54f8b24cf3c36ac to your computer and use it in GitHub Desktop.
Dynamic spy object factory for Jasmine.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export function createSpyObjFactory<T>(ctor: new (...args: Array<any>) => T, includeProto?: boolean, ...args: Array<string>): () => jasmine.SpyObj<T> { | |
return () => includeProto | |
? jasmine.createSpyObj<T>(ctor.name, Object.getOwnPropertyNames(ctor.prototype).concat(Object.getOwnPropertyNames(Object.getPrototypeOf(ctor).prototype)).concat(args)) | |
: jasmine.createSpyObj<T>(ctor.name, Object.getOwnPropertyNames(ctor.prototype).concat(args)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment