Skip to content

Instantly share code, notes, and snippets.

@lijie2000
Created May 19, 2014 18:06
Show Gist options
  • Save lijie2000/a9c09475636d227b03bd to your computer and use it in GitHub Desktop.
Save lijie2000/a9c09475636d227b03bd to your computer and use it in GitHub Desktop.
var mock = function (constr, name) {
var HelperConstr = function(){};
HelperConstr.prototype = constr.prototype;
var result = new HelperConstr();
for (var key in constr.prototype) {
try {
if (constr.prototype[ key ] instanceof Function) {
result[ key ] = jasmine.createSpy(( name || 'mock' ) + '.' + key);
}
} catch (ex) {
}
}
return result;
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment