Skip to content

Instantly share code, notes, and snippets.

@euleule
Created October 13, 2017 11:40
Show Gist options
  • Save euleule/22adeb49a137fdf8ee85b8d459d7f174 to your computer and use it in GitHub Desktop.
Save euleule/22adeb49a137fdf8ee85b8d459d7f174 to your computer and use it in GitHub Desktop.
Mock.ts
/**
* Creates mock object for classes.
*/
export class Mock {
/**
*
* @param {T} classT Class you want to create a mock object for.
* @returns {T} jasmin spy of class T
*/
public static create<T extends { name: string, prototype: Object }>(classT: T): T {
return jasmine.createSpyObj(classT.name, Object.getOwnPropertyNames(classT.prototype));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment