Allow generator functions to be passed to .and.callFake

Fixes #1848.
This commit is contained in:
Steve Gravrock
2020-08-29 13:05:57 -07:00
parent e0eb4755cb
commit 53d8073707
7 changed files with 57 additions and 2 deletions

View File

@@ -168,7 +168,13 @@ getJasmineRequireObj().SpyStrategy = function(j$) {
* @param {Function} fn The function to invoke with the passed parameters.
*/
SpyStrategy.prototype.callFake = function(fn) {
if (!(j$.isFunction_(fn) || j$.isAsyncFunction_(fn))) {
if (
!(
j$.isFunction_(fn) ||
j$.isAsyncFunction_(fn) ||
j$.isGeneratorFunction_(fn)
)
) {
throw new Error(
'Argument passed to callFake should be a function, got ' + fn
);

View File

@@ -76,6 +76,10 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
return j$.isA_('AsyncFunction', value);
};
j$.isGeneratorFunction_ = function(value) {
return j$.isA_('GeneratorFunction', value);
};
j$.isTypedArray_ = function(value) {
return (
j$.isA_('Float32Array', value) ||