From 98fc4f4b2f51cc50985985189ad211cdca9a7be0 Mon Sep 17 00:00:00 2001 From: Emily Wenberg Date: Wed, 1 May 2019 11:35:41 -0700 Subject: [PATCH] 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 --- packages/upgrade/static/src/upgrade_module.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/upgrade/static/src/upgrade_module.ts b/packages/upgrade/static/src/upgrade_module.ts index 1e54a7834a..24a87ae37e 100644 --- a/packages/upgrade/static/src/upgrade_module.ts +++ b/packages/upgrade/static/src/upgrade_module.ts @@ -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; } ]);