refactor(upgrade): use a constant for `$exceptionHandler` (#26217)
PR Close #26217
This commit is contained in:
parent
099d1a67a0
commit
6c5c97b2f9
|
@ -9,6 +9,7 @@
|
|||
export const $COMPILE = '$compile';
|
||||
export const $CONTROLLER = '$controller';
|
||||
export const $DELEGATE = '$delegate';
|
||||
export const $EXCEPTION_HANDLER = '$exceptionHandler';
|
||||
export const $HTTP_BACKEND = '$httpBackend';
|
||||
export const $INJECTOR = '$injector';
|
||||
export const $INTERVAL = '$interval';
|
||||
|
|
|
@ -11,6 +11,7 @@ import {async, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
|||
import {BrowserModule} from '@angular/platform-browser';
|
||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||
import * as angular from '@angular/upgrade/src/common/angular1';
|
||||
import {$EXCEPTION_HANDLER} from '@angular/upgrade/src/common/constants';
|
||||
import {UpgradeAdapter, UpgradeAdapterRef} from '@angular/upgrade/src/dynamic/upgrade_adapter';
|
||||
|
||||
import {$apply, $digest, html, multiTrim, withEachNg1Version} from './test_helpers';
|
||||
|
@ -318,7 +319,7 @@ withEachNg1Version(() => {
|
|||
it('should bind properties, events', async(() => {
|
||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||
const ng1Module =
|
||||
angular.module('ng1', []).value('$exceptionHandler', (err: any) => { throw err; });
|
||||
angular.module('ng1', []).value($EXCEPTION_HANDLER, (err: any) => { throw err; });
|
||||
|
||||
ng1Module.run(($rootScope: any) => {
|
||||
$rootScope.name = 'world';
|
||||
|
@ -2904,7 +2905,7 @@ withEachNg1Version(() => {
|
|||
// Define `ng1Module`
|
||||
const ng1Module =
|
||||
angular.module('ng1Module', [])
|
||||
.value('$exceptionHandler', (error: Error) => errorMessage = error.message)
|
||||
.value($EXCEPTION_HANDLER, (error: Error) => errorMessage = error.message)
|
||||
.component('ng1', ng1Component)
|
||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||
|
||||
|
|
|
@ -22,10 +22,7 @@ withEachNg1Version(() => {
|
|||
afterEach(() => destroyPlatform());
|
||||
|
||||
it('should bind properties, events', async(() => {
|
||||
const ng1Module =
|
||||
angular.module('ng1', []).value('$exceptionHandler', (err: any) => {
|
||||
throw err;
|
||||
}).run(($rootScope: angular.IScope) => {
|
||||
const ng1Module = angular.module('ng1', []).run(($rootScope: angular.IScope) => {
|
||||
$rootScope['name'] = 'world';
|
||||
$rootScope['dataA'] = 'A';
|
||||
$rootScope['dataB'] = 'B';
|
||||
|
@ -149,12 +146,8 @@ withEachNg1Version(() => {
|
|||
}));
|
||||
|
||||
it('should bind properties to onpush components', async(() => {
|
||||
const ng1Module =
|
||||
angular.module('ng1', []).value('$exceptionHandler', (err: any) => {
|
||||
throw err;
|
||||
}).run(($rootScope: angular.IScope) => {
|
||||
$rootScope['dataB'] = 'B';
|
||||
});
|
||||
const ng1Module = angular.module('ng1', []).run(
|
||||
($rootScope: angular.IScope) => { $rootScope['dataB'] = 'B'; });
|
||||
|
||||
@Component({
|
||||
selector: 'ng2',
|
||||
|
|
|
@ -12,7 +12,7 @@ import {BrowserModule} from '@angular/platform-browser';
|
|||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
|
||||
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
||||
import {$SCOPE} from '@angular/upgrade/static/src/common/constants';
|
||||
import {$EXCEPTION_HANDLER, $SCOPE} from '@angular/upgrade/static/src/common/constants';
|
||||
|
||||
import {$digest, bootstrap, html, multiTrim, withEachNg1Version} from '../test_helpers';
|
||||
|
||||
|
@ -1777,7 +1777,7 @@ withEachNg1Version(() => {
|
|||
}
|
||||
|
||||
// Define `ng1Module`
|
||||
const mockExceptionHandler = jasmine.createSpy('$exceptionHandler');
|
||||
const mockExceptionHandler = jasmine.createSpy($EXCEPTION_HANDLER);
|
||||
const ng1Module =
|
||||
angular.module('ng1Module', [])
|
||||
.component('ng1A', ng1ComponentA)
|
||||
|
@ -1786,7 +1786,7 @@ withEachNg1Version(() => {
|
|||
.directive('ng2A', downgradeComponent({component: Ng2ComponentA}))
|
||||
.directive('ng2B', downgradeComponent({component: Ng2ComponentB}))
|
||||
.directive('ng2C', downgradeComponent({component: Ng2ComponentC}))
|
||||
.value('$exceptionHandler', mockExceptionHandler);
|
||||
.value($EXCEPTION_HANDLER, mockExceptionHandler);
|
||||
|
||||
// Define `Ng2Module`
|
||||
@NgModule({
|
||||
|
@ -1849,11 +1849,11 @@ withEachNg1Version(() => {
|
|||
}
|
||||
|
||||
// Define `ng1Module`
|
||||
const mockExceptionHandler = jasmine.createSpy('$exceptionHandler');
|
||||
const mockExceptionHandler = jasmine.createSpy($EXCEPTION_HANDLER);
|
||||
const ng1Module = angular.module('ng1Module', [])
|
||||
.component('ng1', ng1Component)
|
||||
.directive('ng2', downgradeComponent({component: Ng2Component}))
|
||||
.value('$exceptionHandler', mockExceptionHandler);
|
||||
.value($EXCEPTION_HANDLER, mockExceptionHandler);
|
||||
|
||||
// Define `Ng2Module`
|
||||
@NgModule({
|
||||
|
@ -2502,7 +2502,7 @@ withEachNg1Version(() => {
|
|||
// Define `ng1Module`
|
||||
const ng1Module =
|
||||
angular.module('ng1Module', [])
|
||||
.value('$exceptionHandler', (error: Error) => errorMessage = error.message)
|
||||
.value($EXCEPTION_HANDLER, (error: Error) => errorMessage = error.message)
|
||||
.component('ng1', ng1Component)
|
||||
.directive('ng2', downgradeComponent({component: Ng2Component}));
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
import {NgZone, PlatformRef, Type} from '@angular/core';
|
||||
import {UpgradeModule} from '@angular/upgrade/static';
|
||||
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
||||
import {$ROOT_SCOPE} from '@angular/upgrade/static/src/common/constants';
|
||||
import {$EXCEPTION_HANDLER, $ROOT_SCOPE} from '@angular/upgrade/static/src/common/constants';
|
||||
|
||||
import {createWithEachNg1VersionFn} from '../common/test_helpers';
|
||||
export * from '../common/test_helpers';
|
||||
|
@ -22,7 +22,7 @@ export function bootstrap(
|
|||
const ngZone = ref.injector.get<NgZone>(NgZone);
|
||||
const upgrade = ref.injector.get(UpgradeModule);
|
||||
const failHardModule: any = ($provide: angular.IProvideService) => {
|
||||
$provide.value('$exceptionHandler', (err: any) => { throw err; });
|
||||
$provide.value($EXCEPTION_HANDLER, (err: any) => { throw err; });
|
||||
};
|
||||
|
||||
// The `bootstrap()` helper is used for convenience in tests, so that we don't have to inject
|
||||
|
|
Loading…
Reference in New Issue