fix(upgrade): preserve $interval.flush when ngMocks is being used (#30229)
Also preserve any other properties that the user may have decorated $interval with. PR Close #30229
This commit is contained in:
parent
81f61b276b
commit
98fc4f4b2f
|
@ -116,7 +116,7 @@ import {NgAdapterInjector} from './util';
|
|||
*
|
||||
* {@example upgrade/static/ts/full/module.ts region='bootstrap-ng1'}
|
||||
*
|
||||
* Finally, kick off the whole process, by bootstraping your top level Angular `NgModule`.
|
||||
* Finally, kick off the whole process, by bootstrapping your top level Angular `NgModule`.
|
||||
*
|
||||
* {@example upgrade/static/ts/full/module.ts region='bootstrap-ng2'}
|
||||
*
|
||||
|
@ -236,7 +236,17 @@ export class UpgradeModule {
|
|||
});
|
||||
};
|
||||
|
||||
(wrappedInterval as any)['cancel'] = intervalDelegate.cancel;
|
||||
(Object.keys(intervalDelegate) as (keyof IIntervalService)[])
|
||||
.forEach(prop => (wrappedInterval as any)[prop] = intervalDelegate[prop]);
|
||||
|
||||
// the `flush` method will be present when ngMocks is used
|
||||
if (intervalDelegate.hasOwnProperty('flush')) {
|
||||
(wrappedInterval as any)['flush'] = () => {
|
||||
(intervalDelegate as any)['flush']();
|
||||
return wrappedInterval;
|
||||
};
|
||||
}
|
||||
|
||||
return wrappedInterval;
|
||||
}
|
||||
]);
|
||||
|
|
Loading…
Reference in New Issue