Created
May 19, 2014 18:06
-
-
Save lijie2000/a9c09475636d227b03bd to your computer and use it in GitHub Desktop.
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
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