test(upgrade): disable failing ngUpgrade tests when in ivy mode (#27132)
PR Close #27132
This commit is contained in:
parent
a4462c24fa
commit
bc0fbfc93e
@ -7,6 +7,7 @@
|
|||||||
*/
|
*/
|
||||||
import {Compiler, Component, ComponentFactory, Injector, NgModule, TestabilityRegistry} from '@angular/core';
|
import {Compiler, Component, ComponentFactory, Injector, NgModule, TestabilityRegistry} from '@angular/core';
|
||||||
import {TestBed} from '@angular/core/testing';
|
import {TestBed} from '@angular/core/testing';
|
||||||
|
import {fixmeIvy} from '@angular/private/testing';
|
||||||
import * as angular from '@angular/upgrade/src/common/angular1';
|
import * as angular from '@angular/upgrade/src/common/angular1';
|
||||||
import {DowngradeComponentAdapter, groupNodesBySelector} from '@angular/upgrade/src/common/downgrade_component_adapter';
|
import {DowngradeComponentAdapter, groupNodesBySelector} from '@angular/upgrade/src/common/downgrade_component_adapter';
|
||||||
|
|
||||||
@ -177,6 +178,7 @@ withEachNg1Version(() => {
|
|||||||
beforeEach(() => registry.unregisterAllApplications());
|
beforeEach(() => registry.unregisterAllApplications());
|
||||||
afterEach(() => registry.unregisterAllApplications());
|
afterEach(() => registry.unregisterAllApplications());
|
||||||
|
|
||||||
|
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
|
||||||
it('should add testabilities hook when creating components', () => {
|
it('should add testabilities hook when creating components', () => {
|
||||||
|
|
||||||
let registry = TestBed.get(TestabilityRegistry);
|
let registry = TestBed.get(TestabilityRegistry);
|
||||||
@ -188,6 +190,7 @@ withEachNg1Version(() => {
|
|||||||
expect(registry.getAllTestabilities().length).toEqual(2);
|
expect(registry.getAllTestabilities().length).toEqual(2);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
|
||||||
it('should remove the testability hook when destroy a component', () => {
|
it('should remove the testability hook when destroy a component', () => {
|
||||||
const registry = TestBed.get(TestabilityRegistry);
|
const registry = TestBed.get(TestabilityRegistry);
|
||||||
expect(registry.getAllTestabilities().length).toEqual(0);
|
expect(registry.getAllTestabilities().length).toEqual(0);
|
||||||
|
@ -10,6 +10,7 @@ import {ChangeDetectorRef, Component, EventEmitter, Input, NO_ERRORS_SCHEMA, NgM
|
|||||||
import {async, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
import {async, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing';
|
||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||||
|
import {fixmeIvy} from '@angular/private/testing';
|
||||||
import * as angular from '@angular/upgrade/src/common/angular1';
|
import * as angular from '@angular/upgrade/src/common/angular1';
|
||||||
import {$EXCEPTION_HANDLER} from '@angular/upgrade/src/common/constants';
|
import {$EXCEPTION_HANDLER} from '@angular/upgrade/src/common/constants';
|
||||||
import {UpgradeAdapter, UpgradeAdapterRef} from '@angular/upgrade/src/dynamic/upgrade_adapter';
|
import {UpgradeAdapter, UpgradeAdapterRef} from '@angular/upgrade/src/dynamic/upgrade_adapter';
|
||||||
@ -22,12 +23,14 @@ declare global {
|
|||||||
|
|
||||||
withEachNg1Version(() => {
|
withEachNg1Version(() => {
|
||||||
describe('adapter: ng1 to ng2', () => {
|
describe('adapter: ng1 to ng2', () => {
|
||||||
|
|
||||||
beforeEach(() => destroyPlatform());
|
beforeEach(() => destroyPlatform());
|
||||||
afterEach(() => destroyPlatform());
|
afterEach(() => destroyPlatform());
|
||||||
|
|
||||||
describe('(basic use)', () => {
|
describe('(basic use)', () => {
|
||||||
it('should have AngularJS loaded', () => expect(angular.version.major).toBe(1));
|
it('should have AngularJS loaded', () => expect(angular.version.major).toBe(1));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should instantiate ng2 in ng1 template and project content', async(() => {
|
it('should instantiate ng2 in ng1 template and project content', async(() => {
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
|
|
||||||
@ -53,6 +56,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should instantiate ng1 in ng2 template and project content', async(() => {
|
it('should instantiate ng1 in ng2 template and project content', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -72,7 +76,10 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ng1Module.directive('ng1', () => {
|
ng1Module.directive('ng1', () => {
|
||||||
return {transclude: true, template: '{{ "ng1" }}(<ng-transclude></ng-transclude>)'};
|
return {
|
||||||
|
transclude: true,
|
||||||
|
template: '{{ "ng1" }}(<ng-transclude></ng-transclude>)'
|
||||||
|
};
|
||||||
});
|
});
|
||||||
ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2));
|
ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2));
|
||||||
|
|
||||||
@ -142,6 +149,8 @@ withEachNg1Version(() => {
|
|||||||
adapter = new UpgradeAdapter(Ng2Module);
|
adapter = new UpgradeAdapter(Ng2Module);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixmeIvy(
|
||||||
|
'FW-682: JIT compilation occurs at component definition time rather than bootstrap') &&
|
||||||
it('should throw an uncaught error', fakeAsync(() => {
|
it('should throw an uncaught error', fakeAsync(() => {
|
||||||
const resolveSpy = jasmine.createSpy('resolveSpy');
|
const resolveSpy = jasmine.createSpy('resolveSpy');
|
||||||
spyOn(console, 'error');
|
spyOn(console, 'error');
|
||||||
@ -153,6 +162,8 @@ withEachNg1Version(() => {
|
|||||||
expect(resolveSpy).not.toHaveBeenCalled();
|
expect(resolveSpy).not.toHaveBeenCalled();
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy(
|
||||||
|
'FW-682: JIT compilation occurs at component definition time rather than bootstrap') &&
|
||||||
it('should output an error message to the console and re-throw', fakeAsync(() => {
|
it('should output an error message to the console and re-throw', fakeAsync(() => {
|
||||||
const consoleErrorSpy: jasmine.Spy = spyOn(console, 'error');
|
const consoleErrorSpy: jasmine.Spy = spyOn(console, 'error');
|
||||||
expect(() => {
|
expect(() => {
|
||||||
@ -167,6 +178,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('scope/component change-detection', () => {
|
describe('scope/component change-detection', () => {
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should interleave scope and component expressions', async(() => {
|
it('should interleave scope and component expressions', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -193,8 +205,9 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations:
|
declarations: [
|
||||||
[adapter.upgradeNg1Component('ng1a'), adapter.upgradeNg1Component('ng1b'), Ng2],
|
adapter.upgradeNg1Component('ng1a'), adapter.upgradeNg1Component('ng1b'), Ng2
|
||||||
|
],
|
||||||
imports: [BrowserModule],
|
imports: [BrowserModule],
|
||||||
})
|
})
|
||||||
class Ng2Module {
|
class Ng2Module {
|
||||||
@ -213,14 +226,15 @@ withEachNg1Version(() => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
fixmeIvy(
|
||||||
|
'FW-712: Rendering is being run on next "animation frame" rather than "Zone.microTaskEmpty" trigger') &&
|
||||||
it('should propagate changes to a downgraded component inside the ngZone', async(() => {
|
it('should propagate changes to a downgraded component inside the ngZone', async(() => {
|
||||||
let appComponent: AppComponent;
|
let appComponent: AppComponent;
|
||||||
let upgradeRef: UpgradeAdapterRef;
|
let upgradeRef: UpgradeAdapterRef;
|
||||||
|
|
||||||
@Component({selector: 'my-app', template: '<my-child [value]="value"></my-child>'})
|
@Component({selector: 'my-app', template: '<my-child [value]="value"></my-child>'})
|
||||||
class AppComponent {
|
class AppComponent {
|
||||||
// TODO(issue/24571): remove '!'.
|
value?: number;
|
||||||
value !: number;
|
|
||||||
constructor() { appComponent = this; }
|
constructor() { appComponent = this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -229,8 +243,7 @@ withEachNg1Version(() => {
|
|||||||
template: '<div>{{valueFromPromise}}',
|
template: '<div>{{valueFromPromise}}',
|
||||||
})
|
})
|
||||||
class ChildComponent {
|
class ChildComponent {
|
||||||
// TODO(issue/24571): remove '!'.
|
valueFromPromise?: number;
|
||||||
valueFromPromise !: number;
|
|
||||||
@Input()
|
@Input()
|
||||||
set value(v: number) { expect(NgZone.isInAngularZone()).toBe(true); }
|
set value(v: number) { expect(NgZone.isInAngularZone()).toBe(true); }
|
||||||
|
|
||||||
@ -239,12 +252,19 @@ withEachNg1Version(() => {
|
|||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (changes['value'].isFirstChange()) return;
|
if (changes['value'].isFirstChange()) return;
|
||||||
|
|
||||||
|
// HACK(ivy): Using setTimeout allows this test to pass but hides the ivy
|
||||||
|
// renderer timing BC.
|
||||||
|
// setTimeout(() => {
|
||||||
|
// expect(element.textContent).toEqual('5');
|
||||||
|
// upgradeRef.dispose();
|
||||||
|
// }, 0);
|
||||||
this.zone.onMicrotaskEmpty.subscribe(() => {
|
this.zone.onMicrotaskEmpty.subscribe(() => {
|
||||||
expect(element.textContent).toEqual('5');
|
expect(element.textContent).toEqual('5');
|
||||||
upgradeRef.dispose();
|
upgradeRef.dispose();
|
||||||
});
|
});
|
||||||
|
|
||||||
Promise.resolve().then(() => this.valueFromPromise = changes['value'].currentValue);
|
Promise.resolve().then(
|
||||||
|
() => this.valueFromPromise = changes['value'].currentValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,10 +336,11 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-715: ngOnChanges being called a second time unexpectedly') &&
|
||||||
it('should bind properties, events', async(() => {
|
it('should bind properties, events', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module =
|
const ng1Module = angular.module('ng1', []).value(
|
||||||
angular.module('ng1', []).value($EXCEPTION_HANDLER, (err: any) => { throw err; });
|
$EXCEPTION_HANDLER, (err: any) => { throw err; });
|
||||||
|
|
||||||
ng1Module.run(($rootScope: any) => {
|
ng1Module.run(($rootScope: any) => {
|
||||||
$rootScope.name = 'world';
|
$rootScope.name = 'world';
|
||||||
@ -334,7 +355,8 @@ withEachNg1Version(() => {
|
|||||||
selector: 'ng2',
|
selector: 'ng2',
|
||||||
inputs: ['literal', 'interpolate', 'oneWayA', 'oneWayB', 'twoWayA', 'twoWayB'],
|
inputs: ['literal', 'interpolate', 'oneWayA', 'oneWayB', 'twoWayA', 'twoWayB'],
|
||||||
outputs: [
|
outputs: [
|
||||||
'eventA', 'eventB', 'twoWayAEmitter: twoWayAChange', 'twoWayBEmitter: twoWayBChange'
|
'eventA', 'eventB', 'twoWayAEmitter: twoWayAChange',
|
||||||
|
'twoWayBEmitter: twoWayBChange'
|
||||||
],
|
],
|
||||||
template: 'ignore: {{ignore}}; ' +
|
template: 'ignore: {{ignore}}; ' +
|
||||||
'literal: {{literal}}; interpolate: {{interpolate}}; ' +
|
'literal: {{literal}}; interpolate: {{interpolate}}; ' +
|
||||||
@ -438,6 +460,7 @@ withEachNg1Version(() => {
|
|||||||
|
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-715: ngOnChanges being called a second time unexpectedly') &&
|
||||||
it('should support two-way binding and event listener', async(() => {
|
it('should support two-way binding and event listener', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const listenerSpy = jasmine.createSpy('$rootScope.listener');
|
const listenerSpy = jasmine.createSpy('$rootScope.listener');
|
||||||
@ -487,6 +510,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-715: ngOnChanges being called a second time unexpectedly') &&
|
||||||
it('should initialize inputs in time for `ngOnChanges`', async(() => {
|
it('should initialize inputs in time for `ngOnChanges`', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
|
|
||||||
@ -637,6 +661,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-713: ngDestroy not being called when downgraded ng2 component is destroyed') &&
|
||||||
it('should properly run cleanup with multiple levels of nesting', async(() => {
|
it('should properly run cleanup with multiple levels of nesting', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let destroyed = false;
|
let destroyed = false;
|
||||||
@ -716,6 +741,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should support multi-slot projection', async(() => {
|
it('should support multi-slot projection', async(() => {
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
|
|
||||||
@ -745,8 +771,10 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should correctly project structural directives', async(() => {
|
it('should correctly project structural directives', async(() => {
|
||||||
@Component({selector: 'ng2', template: 'ng2-{{ itemId }}(<ng-content></ng-content>)'})
|
@Component(
|
||||||
|
{selector: 'ng2', template: 'ng2-{{ itemId }}(<ng-content></ng-content>)'})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
// TODO(issue/24571): remove '!'.
|
// TODO(issue/24571): remove '!'.
|
||||||
@Input() itemId !: string;
|
@Input() itemId !: string;
|
||||||
@ -757,7 +785,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(Ng2Module);
|
const adapter: UpgradeAdapter = new UpgradeAdapter(Ng2Module);
|
||||||
const ng1Module = angular.module('ng1', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1', [])
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component))
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component))
|
||||||
.run(($rootScope: angular.IRootScopeService) => {
|
.run(($rootScope: angular.IRootScopeService) => {
|
||||||
$rootScope['items'] = [
|
$rootScope['items'] = [
|
||||||
@ -806,6 +835,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('upgrade ng1 component', () => {
|
describe('upgrade ng1 component', () => {
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support `@` bindings', fakeAsync(() => {
|
it('should support `@` bindings', fakeAsync(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let ng2ComponentInstance: Ng2Component;
|
let ng2ComponentInstance: Ng2Component;
|
||||||
@ -851,13 +881,15 @@ withEachNg1Version(() => {
|
|||||||
const ng1 = element.querySelector('ng1') !;
|
const ng1 = element.querySelector('ng1') !;
|
||||||
const ng1Controller = angular.element(ng1).controller !('ng1');
|
const ng1Controller = angular.element(ng1).controller !('ng1');
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
expect(multiTrim(element.textContent))
|
||||||
|
.toBe('Inside: foo, bar | Outside: foo, bar');
|
||||||
|
|
||||||
ng1Controller.inputA = 'baz';
|
ng1Controller.inputA = 'baz';
|
||||||
ng1Controller.inputB = 'qux';
|
ng1Controller.inputB = 'qux';
|
||||||
$digest(ref);
|
$digest(ref);
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('Inside: baz, qux | Outside: foo, bar');
|
expect(multiTrim(element.textContent))
|
||||||
|
.toBe('Inside: baz, qux | Outside: foo, bar');
|
||||||
|
|
||||||
ng2ComponentInstance.dataA = 'foo2';
|
ng2ComponentInstance.dataA = 'foo2';
|
||||||
ng2ComponentInstance.dataB = 'bar2';
|
ng2ComponentInstance.dataB = 'bar2';
|
||||||
@ -870,6 +902,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support `<` bindings', fakeAsync(() => {
|
it('should support `<` bindings', fakeAsync(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let ng2ComponentInstance: Ng2Component;
|
let ng2ComponentInstance: Ng2Component;
|
||||||
@ -915,13 +948,15 @@ withEachNg1Version(() => {
|
|||||||
const ng1 = element.querySelector('ng1') !;
|
const ng1 = element.querySelector('ng1') !;
|
||||||
const ng1Controller = angular.element(ng1).controller !('ng1');
|
const ng1Controller = angular.element(ng1).controller !('ng1');
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
expect(multiTrim(element.textContent))
|
||||||
|
.toBe('Inside: foo, bar | Outside: foo, bar');
|
||||||
|
|
||||||
ng1Controller.inputA = {value: 'baz'};
|
ng1Controller.inputA = {value: 'baz'};
|
||||||
ng1Controller.inputB = {value: 'qux'};
|
ng1Controller.inputB = {value: 'qux'};
|
||||||
$digest(ref);
|
$digest(ref);
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('Inside: baz, qux | Outside: foo, bar');
|
expect(multiTrim(element.textContent))
|
||||||
|
.toBe('Inside: baz, qux | Outside: foo, bar');
|
||||||
|
|
||||||
ng2ComponentInstance.dataA = {value: 'foo2'};
|
ng2ComponentInstance.dataA = {value: 'foo2'};
|
||||||
ng2ComponentInstance.dataB = {value: 'bar2'};
|
ng2ComponentInstance.dataB = {value: 'bar2'};
|
||||||
@ -934,6 +969,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support `=` bindings', fakeAsync(() => {
|
it('should support `=` bindings', fakeAsync(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let ng2ComponentInstance: Ng2Component;
|
let ng2ComponentInstance: Ng2Component;
|
||||||
@ -979,13 +1015,15 @@ withEachNg1Version(() => {
|
|||||||
const ng1 = element.querySelector('ng1') !;
|
const ng1 = element.querySelector('ng1') !;
|
||||||
const ng1Controller = angular.element(ng1).controller !('ng1');
|
const ng1Controller = angular.element(ng1).controller !('ng1');
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
expect(multiTrim(element.textContent))
|
||||||
|
.toBe('Inside: foo, bar | Outside: foo, bar');
|
||||||
|
|
||||||
ng1Controller.inputA = {value: 'baz'};
|
ng1Controller.inputA = {value: 'baz'};
|
||||||
ng1Controller.inputB = {value: 'qux'};
|
ng1Controller.inputB = {value: 'qux'};
|
||||||
$digest(ref);
|
$digest(ref);
|
||||||
|
|
||||||
expect(multiTrim(element.textContent)).toBe('Inside: baz, qux | Outside: baz, qux');
|
expect(multiTrim(element.textContent))
|
||||||
|
.toBe('Inside: baz, qux | Outside: baz, qux');
|
||||||
|
|
||||||
ng2ComponentInstance.dataA = {value: 'foo2'};
|
ng2ComponentInstance.dataA = {value: 'foo2'};
|
||||||
ng2ComponentInstance.dataB = {value: 'bar2'};
|
ng2ComponentInstance.dataB = {value: 'bar2'};
|
||||||
@ -998,6 +1036,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support `&` bindings', fakeAsync(() => {
|
it('should support `&` bindings', fakeAsync(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
|
|
||||||
@ -1052,6 +1091,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should bind properties, events', async(() => {
|
it('should bind properties, events', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -1059,7 +1099,8 @@ withEachNg1Version(() => {
|
|||||||
const ng1 = () => {
|
const ng1 = () => {
|
||||||
return {
|
return {
|
||||||
template: 'Hello {{fullName}}; A: {{modelA}}; B: {{modelB}}; C: {{modelC}}; | ',
|
template: 'Hello {{fullName}}; A: {{modelA}}; B: {{modelB}}; C: {{modelC}}; | ',
|
||||||
scope: {fullName: '@', modelA: '=dataA', modelB: '=dataB', modelC: '=', event: '&'},
|
scope:
|
||||||
|
{fullName: '@', modelA: '=dataA', modelB: '=dataB', modelC: '=', event: '&'},
|
||||||
link: function(scope: any) {
|
link: function(scope: any) {
|
||||||
scope.$watch('modelB', (v: string) => {
|
scope.$watch('modelB', (v: string) => {
|
||||||
if (v == 'Savkin') {
|
if (v == 'Savkin') {
|
||||||
@ -1110,6 +1151,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should bind optional properties', async(() => {
|
it('should bind optional properties', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -1154,6 +1196,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should bind properties, events in controller when bindToController is not used',
|
it('should bind properties, events in controller when bindToController is not used',
|
||||||
async(() => {
|
async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
@ -1164,7 +1207,9 @@ withEachNg1Version(() => {
|
|||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
template: '{{someText}} - Length: {{data.length}}',
|
template: '{{someText}} - Length: {{data.length}}',
|
||||||
scope: {data: '='},
|
scope: {data: '='},
|
||||||
controller: function($scope: any) { $scope.someText = 'ng1 - Data: ' + $scope.data; }
|
controller: function($scope: any) {
|
||||||
|
$scope.someText = 'ng1 - Data: ' + $scope.data;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1199,6 +1244,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should bind properties, events in link function', async(() => {
|
it('should bind properties, events in link function', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -1243,6 +1289,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support templateUrl fetched from $httpBackend', async(() => {
|
it('should support templateUrl fetched from $httpBackend', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -1272,6 +1319,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support templateUrl as a function', async(() => {
|
it('should support templateUrl as a function', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -1353,6 +1401,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support templateUrl fetched from $templateCache', async(() => {
|
it('should support templateUrl fetched from $templateCache', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -1380,6 +1429,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support controller with controllerAs', async(() => {
|
it('should support controller with controllerAs', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -1394,11 +1444,13 @@ withEachNg1Version(() => {
|
|||||||
scope: any; hasElement: string; $element: any; isClass: any;
|
scope: any; hasElement: string; $element: any; isClass: any;
|
||||||
constructor($scope: any, $element: any) {
|
constructor($scope: any, $element: any) {
|
||||||
this.verifyIAmAClass();
|
this.verifyIAmAClass();
|
||||||
this.scope = $scope.$parent.$parent == $scope.$root ? 'scope' : 'wrong-scope';
|
this.scope =
|
||||||
|
$scope.$parent.$parent == $scope.$root ? 'scope' : 'wrong-scope';
|
||||||
this.hasElement = $element[0].nodeName;
|
this.hasElement = $element[0].nodeName;
|
||||||
this.$element = $element;
|
this.$element = $element;
|
||||||
} verifyIAmAClass() { this.isClass = 'isClass'; } isPublished() {
|
} verifyIAmAClass() { this.isClass = 'isClass'; } isPublished() {
|
||||||
return this.$element.controller('ng1') == this ? 'published' : 'not-published';
|
return this.$element.controller('ng1') == this ? 'published' :
|
||||||
|
'not-published';
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -1419,11 +1471,13 @@ withEachNg1Version(() => {
|
|||||||
ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2));
|
ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2));
|
||||||
const element = html(`<div><ng2></ng2></div>`);
|
const element = html(`<div><ng2></ng2></div>`);
|
||||||
adapter.bootstrap(element, ['ng1']).ready((ref) => {
|
adapter.bootstrap(element, ['ng1']).ready((ref) => {
|
||||||
expect(multiTrim(document.body.textContent)).toEqual('scope; isClass; NG1; published');
|
expect(multiTrim(document.body.textContent))
|
||||||
|
.toEqual('scope; isClass; NG1; published');
|
||||||
ref.dispose();
|
ref.dispose();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support bindToController', async(() => {
|
it('should support bindToController', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -1458,6 +1512,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support bindToController with bindings', async(() => {
|
it('should support bindToController with bindings', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -1492,6 +1547,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support single require in linking fn', async(() => {
|
it('should support single require in linking fn', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -1533,6 +1589,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-724: upgraded ng1 components are not being rendered') &&
|
||||||
it('should support array require in linking fn', async(() => {
|
it('should support array require in linking fn', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -1578,6 +1635,7 @@ withEachNg1Version(() => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
describe('with lifecycle hooks', () => {
|
describe('with lifecycle hooks', () => {
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should call `$onInit()` on controller', async(() => {
|
it('should call `$onInit()` on controller', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const $onInitSpyA = jasmine.createSpy('$onInitA');
|
const $onInitSpyA = jasmine.createSpy('$onInitA');
|
||||||
@ -1623,6 +1681,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should not call `$onInit()` on scope', async(() => {
|
it('should not call `$onInit()` on scope', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const $onInitSpy = jasmine.createSpy('$onInit');
|
const $onInitSpy = jasmine.createSpy('$onInit');
|
||||||
@ -1669,6 +1728,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should call `$doCheck()` on controller', async(() => {
|
it('should call `$doCheck()` on controller', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const $doCheckSpyA = jasmine.createSpy('$doCheckA');
|
const $doCheckSpyA = jasmine.createSpy('$doCheckA');
|
||||||
@ -1723,6 +1783,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should not call `$doCheck()` on scope', async(() => {
|
it('should not call `$doCheck()` on scope', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const $doCheckSpyA = jasmine.createSpy('$doCheckA');
|
const $doCheckSpyA = jasmine.createSpy('$doCheckA');
|
||||||
@ -1778,6 +1839,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should call `$postLink()` on controller', async(() => {
|
it('should call `$postLink()` on controller', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const $postLinkSpyA = jasmine.createSpy('$postLinkA');
|
const $postLinkSpyA = jasmine.createSpy('$postLinkA');
|
||||||
@ -1823,6 +1885,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should not call `$postLink()` on scope', async(() => {
|
it('should not call `$postLink()` on scope', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const $postLinkSpy = jasmine.createSpy('$postLink');
|
const $postLinkSpy = jasmine.createSpy('$postLink');
|
||||||
@ -1869,6 +1932,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should call `$onChanges()` on binding destination', fakeAsync(() => {
|
it('should call `$onChanges()` on binding destination', fakeAsync(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const $onChangesControllerSpyA = jasmine.createSpy('$onChangesControllerA');
|
const $onChangesControllerSpyA = jasmine.createSpy('$onChangesControllerA');
|
||||||
@ -1894,15 +1958,15 @@ withEachNg1Version(() => {
|
|||||||
this.$onChanges = $onChangesControllerSpyA;
|
this.$onChanges = $onChangesControllerSpyA;
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.directive(
|
.directive('ng1B', () => ({
|
||||||
'ng1B',
|
|
||||||
() => ({
|
|
||||||
template: '',
|
template: '',
|
||||||
scope: {valB: '<'},
|
scope: {valB: '<'},
|
||||||
bindToController: false,
|
bindToController: false,
|
||||||
controllerAs: '$ctrl',
|
controllerAs: '$ctrl',
|
||||||
controller: class {
|
controller: class {
|
||||||
$onChanges(changes: SimpleChanges) { $onChangesControllerSpyB(changes); }
|
$onChanges(changes: SimpleChanges) {
|
||||||
|
$onChangesControllerSpyB(changes);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component))
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component))
|
||||||
@ -1963,6 +2027,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should call `$onDestroy()` on controller', fakeAsync(() => {
|
it('should call `$onDestroy()` on controller', fakeAsync(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const $onDestroySpyA = jasmine.createSpy('$onDestroyA');
|
const $onDestroySpyA = jasmine.createSpy('$onDestroyA');
|
||||||
@ -1995,7 +2060,8 @@ withEachNg1Version(() => {
|
|||||||
controllerAs: '$ctrl',
|
controllerAs: '$ctrl',
|
||||||
controller: class {$onDestroy() { $onDestroySpyA(); }}
|
controller: class {$onDestroy() { $onDestroySpyA(); }}
|
||||||
}))
|
}))
|
||||||
.directive('ng1B', () => ({
|
.directive(
|
||||||
|
'ng1B', () => ({
|
||||||
template: '',
|
template: '',
|
||||||
scope: {},
|
scope: {},
|
||||||
bindToController: false,
|
bindToController: false,
|
||||||
@ -2053,6 +2119,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should not call `$onDestroy()` on scope', fakeAsync(() => {
|
it('should not call `$onDestroy()` on scope', fakeAsync(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const $onDestroySpy = jasmine.createSpy('$onDestroy');
|
const $onDestroySpy = jasmine.createSpy('$onDestroy');
|
||||||
@ -2083,7 +2150,8 @@ withEachNg1Version(() => {
|
|||||||
bindToController: true,
|
bindToController: true,
|
||||||
controllerAs: '$ctrl',
|
controllerAs: '$ctrl',
|
||||||
controller: function($scope: angular.IScope) {
|
controller: function($scope: angular.IScope) {
|
||||||
Object.getPrototypeOf($scope).$onDestroy = $onDestroySpy;
|
Object.getPrototypeOf($scope).$onDestroy =
|
||||||
|
$onDestroySpy;
|
||||||
}
|
}
|
||||||
}))
|
}))
|
||||||
.directive('ng1B', () => ({
|
.directive('ng1B', () => ({
|
||||||
@ -2135,19 +2203,22 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('destroying the upgraded component', () => {
|
describe('destroying the upgraded component', () => {
|
||||||
|
fixmeIvy('FW-713: ngDestroy not being called when downgraded ng2 component is destroyed') &&
|
||||||
it('should destroy `componentScope`', fakeAsync(() => {
|
it('should destroy `componentScope`', fakeAsync(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const scopeDestroyListener = jasmine.createSpy('scopeDestroyListener');
|
const scopeDestroyListener = jasmine.createSpy('scopeDestroyListener');
|
||||||
let ng2ComponentInstance: Ng2Component;
|
let ng2ComponentInstance: Ng2Component;
|
||||||
|
|
||||||
@Component({selector: 'ng2', template: '<div *ngIf="!ng2Destroy"><ng1></ng1></div>'})
|
@Component(
|
||||||
|
{selector: 'ng2', template: '<div *ngIf="!ng2Destroy"><ng1></ng1></div>'})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
ng2Destroy: boolean = false;
|
ng2Destroy: boolean = false;
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() { ng2ComponentInstance = this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
||||||
// `$animate` will use `setTimeout(..., 16.6)` instead. This timeout will still be on
|
// `$animate` will use `setTimeout(..., 16.6)` instead. This timeout will still be
|
||||||
|
// on
|
||||||
// the queue at the end of the test, causing it to fail.
|
// the queue at the end of the test, causing it to fail.
|
||||||
// Mocking animations (via `ngAnimateMock`) avoids the issue.
|
// Mocking animations (via `ngAnimateMock`) avoids the issue.
|
||||||
angular.module('ng1', ['ngAnimateMock'])
|
angular.module('ng1', ['ngAnimateMock'])
|
||||||
@ -2179,20 +2250,23 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-713: ngDestroy not being called when downgraded ng2 component is destroyed') &&
|
||||||
it('should emit `$destroy` on `$element` and descendants', fakeAsync(() => {
|
it('should emit `$destroy` on `$element` and descendants', fakeAsync(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const elementDestroyListener = jasmine.createSpy('elementDestroyListener');
|
const elementDestroyListener = jasmine.createSpy('elementDestroyListener');
|
||||||
const descendantDestroyListener = jasmine.createSpy('descendantDestroyListener');
|
const descendantDestroyListener = jasmine.createSpy('descendantDestroyListener');
|
||||||
let ng2ComponentInstance: Ng2Component;
|
let ng2ComponentInstance: Ng2Component;
|
||||||
|
|
||||||
@Component({selector: 'ng2', template: '<div *ngIf="!ng2Destroy"><ng1></ng1></div>'})
|
@Component(
|
||||||
|
{selector: 'ng2', template: '<div *ngIf="!ng2Destroy"><ng1></ng1></div>'})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
ng2Destroy: boolean = false;
|
ng2Destroy: boolean = false;
|
||||||
constructor() { ng2ComponentInstance = this; }
|
constructor() { ng2ComponentInstance = this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
// On browsers that don't support `requestAnimationFrame` (IE 9, Android <= 4.3),
|
||||||
// `$animate` will use `setTimeout(..., 16.6)` instead. This timeout will still be on
|
// `$animate` will use `setTimeout(..., 16.6)` instead. This timeout will still be
|
||||||
|
// on
|
||||||
// the queue at the end of the test, causing it to fail.
|
// the queue at the end of the test, causing it to fail.
|
||||||
// Mocking animations (via `ngAnimateMock`) avoids the issue.
|
// Mocking animations (via `ngAnimateMock`) avoids the issue.
|
||||||
angular.module('ng1', ['ngAnimateMock'])
|
angular.module('ng1', ['ngAnimateMock'])
|
||||||
@ -2232,6 +2306,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-713: ngDestroy not being called when downgraded ng2 component is destroyed') &&
|
||||||
it('should clear data on `$element` and descendants', fakeAsync(() => {
|
it('should clear data on `$element` and descendants', fakeAsync(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let ng1ComponentElement: angular.IAugmentedJQuery;
|
let ng1ComponentElement: angular.IAugmentedJQuery;
|
||||||
@ -2296,6 +2371,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-713: ngDestroy not being called when downgraded ng2 component is destroyed') &&
|
||||||
it('should clear dom listeners on `$element` and descendants`', fakeAsync(() => {
|
it('should clear dom listeners on `$element` and descendants`', fakeAsync(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const elementClickListener = jasmine.createSpy('elementClickListener');
|
const elementClickListener = jasmine.createSpy('elementClickListener');
|
||||||
@ -2366,6 +2442,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('linking', () => {
|
describe('linking', () => {
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should run the pre-linking after instantiating the controller', async(() => {
|
it('should run the pre-linking after instantiating the controller', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const log: string[] = [];
|
const log: string[] = [];
|
||||||
@ -2383,7 +2460,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1', [])
|
||||||
.directive('ng1', () => ng1Directive)
|
.directive('ng1', () => ng1Directive)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
@ -2399,10 +2477,11 @@ withEachNg1Version(() => {
|
|||||||
const element = html(`<ng2></ng2>`);
|
const element = html(`<ng2></ng2>`);
|
||||||
|
|
||||||
adapter.bootstrap(element, ['ng1']).ready(() => {
|
adapter.bootstrap(element, ['ng1']).ready(() => {
|
||||||
expect(log).toEqual(['ng1-ctrl', 'ng1-pre']);
|
setTimeout(() => expect(log).toEqual(['ng1-ctrl', 'ng1-pre']), 1000);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should run the pre-linking function before linking', async(() => {
|
it('should run the pre-linking function before linking', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const log: string[] = [];
|
const log: string[] = [];
|
||||||
@ -2421,7 +2500,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1', [])
|
||||||
.directive('ng1A', () => ng1DirectiveA)
|
.directive('ng1A', () => ng1DirectiveA)
|
||||||
.directive('ng1B', () => ng1DirectiveB)
|
.directive('ng1B', () => ng1DirectiveB)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
@ -2443,6 +2523,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should run the post-linking function after linking (link: object)', async(() => {
|
it('should run the post-linking function after linking (link: object)', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const log: string[] = [];
|
const log: string[] = [];
|
||||||
@ -2461,7 +2542,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1', [])
|
||||||
.directive('ng1A', () => ng1DirectiveA)
|
.directive('ng1A', () => ng1DirectiveA)
|
||||||
.directive('ng1B', () => ng1DirectiveB)
|
.directive('ng1B', () => ng1DirectiveB)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
@ -2483,6 +2565,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should run the post-linking function after linking (link: function)', async(() => {
|
it('should run the post-linking function after linking (link: function)', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const log: string[] = [];
|
const log: string[] = [];
|
||||||
@ -2501,7 +2584,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1', [])
|
||||||
.directive('ng1A', () => ng1DirectiveA)
|
.directive('ng1A', () => ng1DirectiveA)
|
||||||
.directive('ng1B', () => ng1DirectiveB)
|
.directive('ng1B', () => ng1DirectiveB)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
@ -2523,6 +2607,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should run the post-linking function before `$postLink`', async(() => {
|
it('should run the post-linking function before `$postLink`', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const log: string[] = [];
|
const log: string[] = [];
|
||||||
@ -2540,7 +2625,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1', [])
|
||||||
.directive('ng1', () => ng1Directive)
|
.directive('ng1', () => ng1Directive)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
@ -2562,6 +2648,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('transclusion', () => {
|
describe('transclusion', () => {
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should support single-slot transclusion', async(() => {
|
it('should support single-slot transclusion', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let ng2ComponentAInstance: Ng2ComponentA;
|
let ng2ComponentAInstance: Ng2ComponentA;
|
||||||
@ -2591,14 +2678,16 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1Module', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1Module', [])
|
||||||
.component('ng1', ng1Component)
|
.component('ng1', ng1Component)
|
||||||
.directive('ng2A', adapter.downgradeNg2Component(Ng2ComponentA));
|
.directive('ng2A', adapter.downgradeNg2Component(Ng2ComponentA));
|
||||||
|
|
||||||
// Define `Ng2Module`
|
// Define `Ng2Module`
|
||||||
@NgModule({
|
@NgModule({
|
||||||
imports: [BrowserModule],
|
imports: [BrowserModule],
|
||||||
declarations: [adapter.upgradeNg1Component('ng1'), Ng2ComponentA, Ng2ComponentB]
|
declarations:
|
||||||
|
[adapter.upgradeNg1Component('ng1'), Ng2ComponentA, Ng2ComponentB]
|
||||||
})
|
})
|
||||||
class Ng2Module {
|
class Ng2Module {
|
||||||
}
|
}
|
||||||
@ -2622,6 +2711,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should support single-slot transclusion with fallback content', async(() => {
|
it('should support single-slot transclusion with fallback content', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let ng1ControllerInstances: any[] = [];
|
let ng1ControllerInstances: any[] = [];
|
||||||
@ -2655,7 +2745,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1Module', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1Module', [])
|
||||||
.component('ng1', ng1Component)
|
.component('ng1', ng1Component)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
@ -2683,6 +2774,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should support multi-slot transclusion', async(() => {
|
it('should support multi-slot transclusion', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let ng2ComponentInstance: Ng2Component;
|
let ng2ComponentInstance: Ng2Component;
|
||||||
@ -2714,7 +2806,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1Module', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1Module', [])
|
||||||
.component('ng1', ng1Component)
|
.component('ng1', ng1Component)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
@ -2743,6 +2836,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should support default slot (with fallback content)', async(() => {
|
it('should support default slot (with fallback content)', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let ng1ControllerInstances: any[] = [];
|
let ng1ControllerInstances: any[] = [];
|
||||||
@ -2788,7 +2882,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1Module', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1Module', [])
|
||||||
.component('ng1', ng1Component)
|
.component('ng1', ng1Component)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
@ -2820,6 +2915,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should support optional transclusion slots (with fallback content)', async(() => {
|
it('should support optional transclusion slots (with fallback content)', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let ng1ControllerInstances: any[] = [];
|
let ng1ControllerInstances: any[] = [];
|
||||||
@ -2854,7 +2950,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1Module', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1Module', [])
|
||||||
.component('ng1', ng1Component)
|
.component('ng1', ng1Component)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
@ -2887,6 +2984,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should throw if a non-optional slot is not filled', async(() => {
|
it('should throw if a non-optional slot is not filled', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let errorMessage: string;
|
let errorMessage: string;
|
||||||
@ -2926,6 +3024,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should support structural directives in transcluded content', async(() => {
|
it('should support structural directives in transcluded content', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
let ng2ComponentInstance: Ng2Component;
|
let ng2ComponentInstance: Ng2Component;
|
||||||
@ -2958,7 +3057,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1Module', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1Module', [])
|
||||||
.component('ng1', ng1Component)
|
.component('ng1', ng1Component)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
@ -2975,30 +3075,35 @@ withEachNg1Version(() => {
|
|||||||
const element = html(`<ng2></ng2>`);
|
const element = html(`<ng2></ng2>`);
|
||||||
|
|
||||||
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
adapter.bootstrap(element, ['ng1Module']).ready(ref => {
|
||||||
expect(multiTrim(element.textContent, true)).toBe('ng2(ng1(x(foo1)|default(bar2)))');
|
expect(multiTrim(element.textContent, true))
|
||||||
|
.toBe('ng2(ng1(x(foo1)|default(bar2)))');
|
||||||
|
|
||||||
ng2ComponentInstance.x = 'baz';
|
ng2ComponentInstance.x = 'baz';
|
||||||
ng2ComponentInstance.y = 'qux';
|
ng2ComponentInstance.y = 'qux';
|
||||||
ng2ComponentInstance.show = false;
|
ng2ComponentInstance.show = false;
|
||||||
$digest(ref);
|
$digest(ref);
|
||||||
|
|
||||||
expect(multiTrim(element.textContent, true)).toBe('ng2(ng1(x(baz2)|default(qux1)))');
|
expect(multiTrim(element.textContent, true))
|
||||||
|
.toBe('ng2(ng1(x(baz2)|default(qux1)))');
|
||||||
|
|
||||||
ng2ComponentInstance.show = true;
|
ng2ComponentInstance.show = true;
|
||||||
$digest(ref);
|
$digest(ref);
|
||||||
|
|
||||||
expect(multiTrim(element.textContent, true)).toBe('ng2(ng1(x(baz1)|default(qux2)))');
|
expect(multiTrim(element.textContent, true))
|
||||||
|
.toBe('ng2(ng1(x(baz1)|default(qux2)))');
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should bind input properties (<) of components', async(() => {
|
it('should bind input properties (<) of components', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
|
|
||||||
const ng1 = {
|
const ng1 = {
|
||||||
bindings: {personProfile: '<'},
|
bindings: {personProfile: '<'},
|
||||||
template: 'Hello {{$ctrl.personProfile.firstName}} {{$ctrl.personProfile.lastName}}',
|
template:
|
||||||
|
'Hello {{$ctrl.personProfile.firstName}} {{$ctrl.personProfile.lastName}}',
|
||||||
controller: class {}
|
controller: class {}
|
||||||
};
|
};
|
||||||
ng1Module.component('ng1', ng1);
|
ng1Module.component('ng1', ng1);
|
||||||
@ -3024,6 +3129,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('unknown') &&
|
||||||
it('should support ng2 > ng1 > ng2', async(() => {
|
it('should support ng2 > ng1 > ng2', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
@ -3096,10 +3202,12 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should respect hierarchical dependency injection for ng2', async(() => {
|
it('should respect hierarchical dependency injection for ng2', async(() => {
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
|
|
||||||
@Component({selector: 'ng2-parent', template: `ng2-parent(<ng-content></ng-content>)`})
|
@Component(
|
||||||
|
{selector: 'ng2-parent', template: `ng2-parent(<ng-content></ng-content>)`})
|
||||||
class Ng2Parent {
|
class Ng2Parent {
|
||||||
}
|
}
|
||||||
@Component({selector: 'ng2-child', template: `ng2-child`})
|
@Component({selector: 'ng2-child', template: `ng2-child`})
|
||||||
@ -3197,6 +3305,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('examples', () => {
|
describe('examples', () => {
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should verify UpgradeAdapter example', async(() => {
|
it('should verify UpgradeAdapter example', async(() => {
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
const module = angular.module('myExample', []);
|
const module = angular.module('myExample', []);
|
||||||
|
@ -10,6 +10,7 @@ import {Component, Directive, ElementRef, Injector, Input, NgModule, NgZone, Sim
|
|||||||
import {async} from '@angular/core/testing';
|
import {async} from '@angular/core/testing';
|
||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||||
|
import {fixmeIvy} from '@angular/private/testing';
|
||||||
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
|
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
|
||||||
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
||||||
|
|
||||||
@ -75,13 +76,15 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy(
|
||||||
|
'FW-712: Rendering is being run on next "animation frame" rather than "Zone.microTaskEmpty" trigger') &&
|
||||||
it('should propagate changes to a downgraded component inside the ngZone', async(() => {
|
it('should propagate changes to a downgraded component inside the ngZone', async(() => {
|
||||||
|
const element = html('<my-app></my-app>');
|
||||||
let appComponent: AppComponent;
|
let appComponent: AppComponent;
|
||||||
|
|
||||||
@Component({selector: 'my-app', template: '<my-child [value]="value"></my-child>'})
|
@Component({selector: 'my-app', template: '<my-child [value]="value"></my-child>'})
|
||||||
class AppComponent {
|
class AppComponent {
|
||||||
// TODO(issue/24571): remove '!'.
|
value?: number;
|
||||||
value !: number;
|
|
||||||
constructor() { appComponent = this; }
|
constructor() { appComponent = this; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,8 +93,7 @@ withEachNg1Version(() => {
|
|||||||
template: '<div>{{ valueFromPromise }}</div>',
|
template: '<div>{{ valueFromPromise }}</div>',
|
||||||
})
|
})
|
||||||
class ChildComponent {
|
class ChildComponent {
|
||||||
// TODO(issue/24571): remove '!'.
|
valueFromPromise?: number;
|
||||||
valueFromPromise !: number;
|
|
||||||
@Input()
|
@Input()
|
||||||
set value(v: number) { expect(NgZone.isInAngularZone()).toBe(true); }
|
set value(v: number) { expect(NgZone.isInAngularZone()).toBe(true); }
|
||||||
|
|
||||||
@ -100,10 +102,15 @@ withEachNg1Version(() => {
|
|||||||
ngOnChanges(changes: SimpleChanges) {
|
ngOnChanges(changes: SimpleChanges) {
|
||||||
if (changes['value'].isFirstChange()) return;
|
if (changes['value'].isFirstChange()) return;
|
||||||
|
|
||||||
|
// HACK(ivy): Using setTimeout allows this test to pass but hides the ivy renderer
|
||||||
|
// timing BC.
|
||||||
|
// setTimeout(() => expect(element.textContent).toEqual('5'), 0);
|
||||||
this.zone.onMicrotaskEmpty.subscribe(
|
this.zone.onMicrotaskEmpty.subscribe(
|
||||||
() => { expect(element.textContent).toEqual('5'); });
|
() => { expect(element.textContent).toEqual('5'); });
|
||||||
|
|
||||||
Promise.resolve().then(() => this.valueFromPromise = changes['value'].currentValue);
|
// Create a micro-task to update the value to be rendered asynchronously.
|
||||||
|
Promise.resolve().then(
|
||||||
|
() => this.valueFromPromise = changes['value'].currentValue);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -119,9 +126,6 @@ withEachNg1Version(() => {
|
|||||||
const ng1Module = angular.module('ng1', []).directive(
|
const ng1Module = angular.module('ng1', []).directive(
|
||||||
'myApp', downgradeComponent({component: AppComponent}));
|
'myApp', downgradeComponent({component: AppComponent}));
|
||||||
|
|
||||||
|
|
||||||
const element = html('<my-app></my-app>');
|
|
||||||
|
|
||||||
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then((upgrade) => {
|
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then((upgrade) => {
|
||||||
appComponent.value = 5;
|
appComponent.value = 5;
|
||||||
});
|
});
|
||||||
|
@ -10,6 +10,7 @@ import {Component, Directive, ElementRef, Injector, Input, NgModule, destroyPlat
|
|||||||
import {async} from '@angular/core/testing';
|
import {async} from '@angular/core/testing';
|
||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||||
|
import {fixmeIvy} from '@angular/private/testing';
|
||||||
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
|
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
|
||||||
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ withEachNg1Version(() => {
|
|||||||
beforeEach(() => destroyPlatform());
|
beforeEach(() => destroyPlatform());
|
||||||
afterEach(() => destroyPlatform());
|
afterEach(() => destroyPlatform());
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should instantiate ng2 in ng1 template and project content', async(() => {
|
it('should instantiate ng2 in ng1 template and project content', async(() => {
|
||||||
|
|
||||||
// the ng2 component that will be used in ng1 (downgraded)
|
// the ng2 component that will be used in ng1 (downgraded)
|
||||||
@ -50,13 +52,15 @@ withEachNg1Version(() => {
|
|||||||
$rootScope['ngContent'] = 'ng1-content';
|
$rootScope['ngContent'] = 'ng1-content';
|
||||||
});
|
});
|
||||||
|
|
||||||
const element = html('<div>{{ \'ng1[\' }}<ng2>~{{ ngContent }}~</ng2>{{ \']\' }}</div>');
|
const element =
|
||||||
|
html('<div>{{ \'ng1[\' }}<ng2>~{{ ngContent }}~</ng2>{{ \']\' }}</div>');
|
||||||
|
|
||||||
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then((upgrade) => {
|
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then((upgrade) => {
|
||||||
expect(document.body.textContent).toEqual('ng1[NG2(~ng1-content~)]');
|
expect(document.body.textContent).toEqual('ng1[NG2(~ng1-content~)]');
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should correctly project structural directives', async(() => {
|
it('should correctly project structural directives', async(() => {
|
||||||
@Component({selector: 'ng2', template: 'ng2-{{ itemId }}(<ng-content></ng-content>)'})
|
@Component({selector: 'ng2', template: 'ng2-{{ itemId }}(<ng-content></ng-content>)'})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
@ -73,7 +77,8 @@ withEachNg1Version(() => {
|
|||||||
ngDoBootstrap() {}
|
ngDoBootstrap() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ng1Module = angular.module('ng1', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1', [])
|
||||||
.directive('ng2', downgradeComponent({component: Ng2Component}))
|
.directive('ng2', downgradeComponent({component: Ng2Component}))
|
||||||
.run(($rootScope: angular.IRootScopeService) => {
|
.run(($rootScope: angular.IRootScopeService) => {
|
||||||
$rootScope['items'] = [
|
$rootScope['items'] = [
|
||||||
@ -140,6 +145,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should support multi-slot projection', async(() => {
|
it('should support multi-slot projection', async(() => {
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
|
@ -10,6 +10,7 @@ import {ChangeDetectionStrategy, ChangeDetectorRef, Compiler, Component, Compone
|
|||||||
import {async, fakeAsync, tick} from '@angular/core/testing';
|
import {async, fakeAsync, tick} from '@angular/core/testing';
|
||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||||
|
import {fixmeIvy} from '@angular/private/testing';
|
||||||
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
|
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
|
||||||
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
||||||
|
|
||||||
@ -21,6 +22,7 @@ withEachNg1Version(() => {
|
|||||||
beforeEach(() => destroyPlatform());
|
beforeEach(() => destroyPlatform());
|
||||||
afterEach(() => destroyPlatform());
|
afterEach(() => destroyPlatform());
|
||||||
|
|
||||||
|
fixmeIvy('FW-716: Error: [$rootScope:inprog] $digest already in progress') &&
|
||||||
it('should bind properties, events', async(() => {
|
it('should bind properties, events', async(() => {
|
||||||
const ng1Module = angular.module('ng1', []).run(($rootScope: angular.IScope) => {
|
const ng1Module = angular.module('ng1', []).run(($rootScope: angular.IScope) => {
|
||||||
$rootScope['name'] = 'world';
|
$rootScope['name'] = 'world';
|
||||||
@ -36,7 +38,8 @@ withEachNg1Version(() => {
|
|||||||
selector: 'ng2',
|
selector: 'ng2',
|
||||||
inputs: ['literal', 'interpolate', 'oneWayA', 'oneWayB', 'twoWayA', 'twoWayB'],
|
inputs: ['literal', 'interpolate', 'oneWayA', 'oneWayB', 'twoWayA', 'twoWayB'],
|
||||||
outputs: [
|
outputs: [
|
||||||
'eventA', 'eventB', 'twoWayAEmitter: twoWayAChange', 'twoWayBEmitter: twoWayBChange'
|
'eventA', 'eventB', 'twoWayAEmitter: twoWayAChange',
|
||||||
|
'twoWayBEmitter: twoWayBChange'
|
||||||
],
|
],
|
||||||
template: 'ignore: {{ignore}}; ' +
|
template: 'ignore: {{ignore}}; ' +
|
||||||
'literal: {{literal}}; interpolate: {{interpolate}}; ' +
|
'literal: {{literal}}; interpolate: {{interpolate}}; ' +
|
||||||
@ -186,6 +189,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-715: ngOnChanges being called a second time unexpectedly') &&
|
||||||
it('should support two-way binding and event listener', async(() => {
|
it('should support two-way binding and event listener', async(() => {
|
||||||
const listenerSpy = jasmine.createSpy('$rootScope.listener');
|
const listenerSpy = jasmine.createSpy('$rootScope.listener');
|
||||||
const ng1Module = angular.module('ng1', []).run(($rootScope: angular.IScope) => {
|
const ng1Module = angular.module('ng1', []).run(($rootScope: angular.IScope) => {
|
||||||
@ -400,6 +404,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-715: ngOnChanges being called a second time unexpectedly') &&
|
||||||
it('should initialize inputs in time for `ngOnChanges`', async(() => {
|
it('should initialize inputs in time for `ngOnChanges`', async(() => {
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ng2',
|
selector: 'ng2',
|
||||||
@ -515,6 +520,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-713: ngDestroy not being called when downgraded ng2 component is destroyed') &&
|
||||||
it('should properly run cleanup when ng1 directive is destroyed', async(() => {
|
it('should properly run cleanup when ng1 directive is destroyed', async(() => {
|
||||||
|
|
||||||
let destroyed = false;
|
let destroyed = false;
|
||||||
@ -553,6 +559,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-642: ASSERTION ERROR: Slot should have been initialized to NO_CHANGE') &&
|
||||||
it('should properly run cleanup with multiple levels of nesting', async(() => {
|
it('should properly run cleanup with multiple levels of nesting', async(() => {
|
||||||
let destroyed = false;
|
let destroyed = false;
|
||||||
|
|
||||||
@ -704,6 +711,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should respect hierarchical dependency injection for ng2', async(() => {
|
it('should respect hierarchical dependency injection for ng2', async(() => {
|
||||||
@Component({selector: 'parent', template: 'parent(<ng-content></ng-content>)'})
|
@Component({selector: 'parent', template: 'parent(<ng-content></ng-content>)'})
|
||||||
class ParentComponent {
|
class ParentComponent {
|
||||||
@ -735,6 +743,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-561: Runtime compiler is not loaded') &&
|
||||||
it('should work with ng2 lazy loaded components', async(() => {
|
it('should work with ng2 lazy loaded components', async(() => {
|
||||||
|
|
||||||
let componentInjector: Injector;
|
let componentInjector: Injector;
|
||||||
|
@ -11,6 +11,7 @@ import {async, fakeAsync, tick} from '@angular/core/testing';
|
|||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||||
import {browserDetection} from '@angular/platform-browser/testing/src/browser_util';
|
import {browserDetection} from '@angular/platform-browser/testing/src/browser_util';
|
||||||
|
import {fixmeIvy} from '@angular/private/testing';
|
||||||
import {downgradeComponent, downgradeModule} from '@angular/upgrade/static';
|
import {downgradeComponent, downgradeModule} from '@angular/upgrade/static';
|
||||||
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
||||||
import {$EXCEPTION_HANDLER, $ROOT_SCOPE, INJECTOR_KEY, LAZY_MODULE_REF} from '@angular/upgrade/static/src/common/constants';
|
import {$EXCEPTION_HANDLER, $ROOT_SCOPE, INJECTOR_KEY, LAZY_MODULE_REF} from '@angular/upgrade/static/src/common/constants';
|
||||||
@ -131,6 +132,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-718: upgraded service not being initialized correctly on the injector') &&
|
||||||
it('should support using an upgraded service', async(() => {
|
it('should support using an upgraded service', async(() => {
|
||||||
class Ng2Service {
|
class Ng2Service {
|
||||||
constructor(@Inject('ng1Value') private ng1Value: string) {}
|
constructor(@Inject('ng1Value') private ng1Value: string) {}
|
||||||
@ -165,7 +167,8 @@ withEachNg1Version(() => {
|
|||||||
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
||||||
const ng1Module =
|
const ng1Module =
|
||||||
angular.module('ng1', [lazyModuleName])
|
angular.module('ng1', [lazyModuleName])
|
||||||
.directive('ng2', downgradeComponent({component: Ng2Component, propagateDigest}))
|
.directive(
|
||||||
|
'ng2', downgradeComponent({component: Ng2Component, propagateDigest}))
|
||||||
.value('ng1Value', 'foo');
|
.value('ng1Value', 'foo');
|
||||||
|
|
||||||
const element = html('<div><ng2 ng-if="loadNg2"></ng2></div>');
|
const element = html('<div><ng2 ng-if="loadNg2"></ng2></div>');
|
||||||
@ -222,6 +225,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-713: ngDestroy not being called when downgraded ng2 component is destroyed') &&
|
||||||
it('should destroy components inside the Angular zone', async(() => {
|
it('should destroy components inside the Angular zone', async(() => {
|
||||||
let destroyedInTheZone = false;
|
let destroyedInTheZone = false;
|
||||||
|
|
||||||
@ -258,6 +262,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-715: ngOnChanges being called a second time unexpectedly') &&
|
||||||
it('should propagate input changes inside the Angular zone', async(() => {
|
it('should propagate input changes inside the Angular zone', async(() => {
|
||||||
let ng2Component: Ng2Component;
|
let ng2Component: Ng2Component;
|
||||||
|
|
||||||
@ -284,13 +289,15 @@ withEachNg1Version(() => {
|
|||||||
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
||||||
const ng1Module =
|
const ng1Module =
|
||||||
angular.module('ng1', [lazyModuleName])
|
angular.module('ng1', [lazyModuleName])
|
||||||
.directive('ng2', downgradeComponent({component: Ng2Component, propagateDigest}))
|
.directive(
|
||||||
|
'ng2', downgradeComponent({component: Ng2Component, propagateDigest}))
|
||||||
.run(($rootScope: angular.IRootScopeService) => {
|
.run(($rootScope: angular.IRootScopeService) => {
|
||||||
$rootScope.attrVal = 'bar';
|
$rootScope.attrVal = 'bar';
|
||||||
$rootScope.propVal = 'bar';
|
$rootScope.propVal = 'bar';
|
||||||
});
|
});
|
||||||
|
|
||||||
const element = html('<ng2 attr-input="{{ attrVal }}" [prop-input]="propVal"></ng2>');
|
const element =
|
||||||
|
html('<ng2 attr-input="{{ attrVal }}" [prop-input]="propVal"></ng2>');
|
||||||
const $injector = angular.bootstrap(element, [ng1Module.name]);
|
const $injector = angular.bootstrap(element, [ng1Module.name]);
|
||||||
const $rootScope = $injector.get($ROOT_SCOPE) as angular.IRootScopeService;
|
const $rootScope = $injector.get($ROOT_SCOPE) as angular.IRootScopeService;
|
||||||
|
|
||||||
@ -358,6 +365,8 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-715: ngOnChanges being called a second time unexpectedly') &&
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should run the lifecycle hooks in the correct order', async(() => {
|
it('should run the lifecycle hooks in the correct order', async(() => {
|
||||||
const logs: string[] = [];
|
const logs: string[] = [];
|
||||||
let rootScope: angular.IRootScopeService;
|
let rootScope: angular.IRootScopeService;
|
||||||
@ -401,7 +410,8 @@ withEachNg1Version(() => {
|
|||||||
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
const lazyModuleName = downgradeModule<Ng2Module>(bootstrapFn);
|
||||||
const ng1Module =
|
const ng1Module =
|
||||||
angular.module('ng1', [lazyModuleName])
|
angular.module('ng1', [lazyModuleName])
|
||||||
.directive('ng2', downgradeComponent({component: Ng2Component, propagateDigest}))
|
.directive(
|
||||||
|
'ng2', downgradeComponent({component: Ng2Component, propagateDigest}))
|
||||||
.run(($rootScope: angular.IRootScopeService) => {
|
.run(($rootScope: angular.IRootScopeService) => {
|
||||||
rootScope = $rootScope;
|
rootScope = $rootScope;
|
||||||
rootScope.value = 'bar';
|
rootScope.value = 'bar';
|
||||||
@ -420,7 +430,8 @@ withEachNg1Version(() => {
|
|||||||
expect(logs).toEqual([
|
expect(logs).toEqual([
|
||||||
// `ngOnChanges()` call triggered directly through the `inputChanges` $watcher.
|
// `ngOnChanges()` call triggered directly through the `inputChanges` $watcher.
|
||||||
'OnChanges(bar)',
|
'OnChanges(bar)',
|
||||||
// Initial CD triggered directly through the `detectChanges()` or `inputChanges`
|
// Initial CD triggered directly through the `detectChanges()` or
|
||||||
|
// `inputChanges`
|
||||||
// $watcher (for `propagateDigest` true/false respectively).
|
// $watcher (for `propagateDigest` true/false respectively).
|
||||||
'OnInit(bar)',
|
'OnInit(bar)',
|
||||||
'DoCheck(bar)',
|
'DoCheck(bar)',
|
||||||
@ -486,7 +497,8 @@ withEachNg1Version(() => {
|
|||||||
'DoCheck(baz)',
|
'DoCheck(baz)',
|
||||||
'AfterContentChecked(baz)',
|
'AfterContentChecked(baz)',
|
||||||
'AfterViewChecked(baz)',
|
'AfterViewChecked(baz)',
|
||||||
// CD triggered due to entering/leaving the NgZone (in the above $watcher).
|
// CD triggered due to entering/leaving the NgZone (in the above
|
||||||
|
// $watcher).
|
||||||
'DoCheck(baz)',
|
'DoCheck(baz)',
|
||||||
'AfterContentChecked(baz)',
|
'AfterContentChecked(baz)',
|
||||||
'AfterViewChecked(baz)',
|
'AfterViewChecked(baz)',
|
||||||
@ -514,6 +526,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-717: Browser locks up and disconnects') &&
|
||||||
it('should detach hostViews from the ApplicationRef once destroyed', async(() => {
|
it('should detach hostViews from the ApplicationRef once destroyed', async(() => {
|
||||||
let ng2Component: Ng2Component;
|
let ng2Component: Ng2Component;
|
||||||
|
|
||||||
|
@ -10,6 +10,7 @@ import {Component, Directive, ElementRef, Injector, Input, NgModule, destroyPlat
|
|||||||
import {async} from '@angular/core/testing';
|
import {async} from '@angular/core/testing';
|
||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||||
|
import {fixmeIvy} from '@angular/private/testing';
|
||||||
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
|
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
|
||||||
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
||||||
|
|
||||||
@ -23,6 +24,7 @@ withEachNg1Version(() => {
|
|||||||
|
|
||||||
it('should have AngularJS loaded', () => expect(angular.version.major).toBe(1));
|
it('should have AngularJS loaded', () => expect(angular.version.major).toBe(1));
|
||||||
|
|
||||||
|
fixmeIvy('FW-714: ng1 projected content is not being rendered') &&
|
||||||
it('should verify UpgradeAdapter example', async(() => {
|
it('should verify UpgradeAdapter example', async(() => {
|
||||||
|
|
||||||
// This is wrapping (upgrading) an AngularJS component to be used in an Angular
|
// This is wrapping (upgrading) an AngularJS component to be used in an Angular
|
||||||
@ -54,7 +56,8 @@ withEachNg1Version(() => {
|
|||||||
imports: [BrowserModule, UpgradeModule]
|
imports: [BrowserModule, UpgradeModule]
|
||||||
})
|
})
|
||||||
class Ng2Module {
|
class Ng2Module {
|
||||||
ngDoBootstrap() { /* this is a placeholder to stop the bootstrapper from complaining */
|
ngDoBootstrap() { /* this is a placeholder to stop the bootstrapper from
|
||||||
|
complaining */
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +75,8 @@ withEachNg1Version(() => {
|
|||||||
template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)'
|
template: 'ng1[Hello {{title}}!](<span ng-transclude></span>)'
|
||||||
};
|
};
|
||||||
})
|
})
|
||||||
// This is wrapping (downgrading) an Angular component to be used in AngularJS
|
// This is wrapping (downgrading) an Angular component to be used in
|
||||||
|
// AngularJS
|
||||||
.directive('ng2', downgradeComponent({component: Ng2Component}));
|
.directive('ng2', downgradeComponent({component: Ng2Component}));
|
||||||
|
|
||||||
// This is the (AngularJS) application bootstrap element
|
// This is the (AngularJS) application bootstrap element
|
||||||
|
@ -10,6 +10,7 @@ import {Component, Directive, ElementRef, ErrorHandler, EventEmitter, Inject, In
|
|||||||
import {async, fakeAsync, tick} from '@angular/core/testing';
|
import {async, fakeAsync, tick} from '@angular/core/testing';
|
||||||
import {BrowserModule} from '@angular/platform-browser';
|
import {BrowserModule} from '@angular/platform-browser';
|
||||||
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
import {platformBrowserDynamic} from '@angular/platform-browser-dynamic';
|
||||||
|
import {fixmeIvy} from '@angular/private/testing';
|
||||||
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
|
import {UpgradeComponent, UpgradeModule, downgradeComponent} from '@angular/upgrade/static';
|
||||||
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
import * as angular from '@angular/upgrade/static/src/common/angular1';
|
||||||
import {$EXCEPTION_HANDLER, $SCOPE} from '@angular/upgrade/static/src/common/constants';
|
import {$EXCEPTION_HANDLER, $SCOPE} from '@angular/upgrade/static/src/common/constants';
|
||||||
@ -2133,13 +2134,17 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('transclusion', () => {
|
describe('transclusion', () => {
|
||||||
|
fixmeIvy(
|
||||||
|
`Error: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`) &&
|
||||||
it('should support single-slot transclusion', async(() => {
|
it('should support single-slot transclusion', async(() => {
|
||||||
let ng2ComponentAInstance: Ng2ComponentA;
|
let ng2ComponentAInstance: Ng2ComponentA;
|
||||||
let ng2ComponentBInstance: Ng2ComponentB;
|
let ng2ComponentBInstance: Ng2ComponentB;
|
||||||
|
|
||||||
// Define `ng1Component`
|
// Define `ng1Component`
|
||||||
const ng1Component:
|
const ng1Component: angular.IComponent = {
|
||||||
angular.IComponent = {template: 'ng1(<div ng-transclude></div>)', transclude: true};
|
template: 'ng1(<div ng-transclude></div>)',
|
||||||
|
transclude: true
|
||||||
|
};
|
||||||
|
|
||||||
// Define `Ng1ComponentFacade`
|
// Define `Ng1ComponentFacade`
|
||||||
@Directive({selector: 'ng1'})
|
@Directive({selector: 'ng1'})
|
||||||
@ -2167,7 +2172,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1Module', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1Module', [])
|
||||||
.component('ng1', ng1Component)
|
.component('ng1', ng1Component)
|
||||||
.directive('ng2A', downgradeComponent({component: Ng2ComponentA}));
|
.directive('ng2A', downgradeComponent({component: Ng2ComponentA}));
|
||||||
|
|
||||||
@ -2525,6 +2531,8 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy(
|
||||||
|
`Error: Failed to execute 'insertBefore' on 'Node': The node before which the new node is to be inserted is not a child of this node.`) &&
|
||||||
it('should support structural directives in transcluded content', async(() => {
|
it('should support structural directives in transcluded content', async(() => {
|
||||||
let ng2ComponentInstance: Ng2Component;
|
let ng2ComponentInstance: Ng2Component;
|
||||||
|
|
||||||
@ -2564,7 +2572,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1Module', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1Module', [])
|
||||||
.component('ng1', ng1Component)
|
.component('ng1', ng1Component)
|
||||||
.directive('ng2', downgradeComponent({component: Ng2Component}));
|
.directive('ng2', downgradeComponent({component: Ng2Component}));
|
||||||
|
|
||||||
@ -2583,19 +2592,22 @@ withEachNg1Version(() => {
|
|||||||
const element = html(`<ng2></ng2>`);
|
const element = html(`<ng2></ng2>`);
|
||||||
|
|
||||||
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then(adapter => {
|
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then(adapter => {
|
||||||
expect(multiTrim(element.textContent, true)).toBe('ng2(ng1(x(foo1)|default(bar2)))');
|
expect(multiTrim(element.textContent, true))
|
||||||
|
.toBe('ng2(ng1(x(foo1)|default(bar2)))');
|
||||||
|
|
||||||
ng2ComponentInstance.x = 'baz';
|
ng2ComponentInstance.x = 'baz';
|
||||||
ng2ComponentInstance.y = 'qux';
|
ng2ComponentInstance.y = 'qux';
|
||||||
ng2ComponentInstance.show = false;
|
ng2ComponentInstance.show = false;
|
||||||
$digest(adapter);
|
$digest(adapter);
|
||||||
|
|
||||||
expect(multiTrim(element.textContent, true)).toBe('ng2(ng1(x(baz2)|default(qux1)))');
|
expect(multiTrim(element.textContent, true))
|
||||||
|
.toBe('ng2(ng1(x(baz2)|default(qux1)))');
|
||||||
|
|
||||||
ng2ComponentInstance.show = true;
|
ng2ComponentInstance.show = true;
|
||||||
$digest(adapter);
|
$digest(adapter);
|
||||||
|
|
||||||
expect(multiTrim(element.textContent, true)).toBe('ng2(ng1(x(baz1)|default(qux2)))');
|
expect(multiTrim(element.textContent, true))
|
||||||
|
.toBe('ng2(ng1(x(baz1)|default(qux2)))');
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
});
|
});
|
||||||
@ -3324,6 +3336,7 @@ withEachNg1Version(() => {
|
|||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
|
fixmeIvy('FW-713: ngDestroy not being called when downgraded ng2 component is destroyed') &&
|
||||||
it('should call `$onDestroy()` on controller', async(() => {
|
it('should call `$onDestroy()` on controller', async(() => {
|
||||||
const controllerOnDestroyA = jasmine.createSpy('controllerOnDestroyA');
|
const controllerOnDestroyA = jasmine.createSpy('controllerOnDestroyA');
|
||||||
const controllerOnDestroyB = jasmine.createSpy('controllerOnDestroyB');
|
const controllerOnDestroyB = jasmine.createSpy('controllerOnDestroyB');
|
||||||
@ -3362,15 +3375,18 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `Ng2Component`
|
// Define `Ng2Component`
|
||||||
@Component(
|
@Component({
|
||||||
{selector: 'ng2', template: '<div *ngIf="show"><ng1A></ng1A> | <ng1B></ng1B></div>'})
|
selector: 'ng2',
|
||||||
|
template: '<div *ngIf="show"><ng1A></ng1A> | <ng1B></ng1B></div>'
|
||||||
|
})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
// TODO(issue/24571): remove '!'.
|
// TODO(issue/24571): remove '!'.
|
||||||
@Input() show !: boolean;
|
@Input() show !: boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1Module', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1Module', [])
|
||||||
.directive('ng1A', () => ng1DirectiveA)
|
.directive('ng1A', () => ng1DirectiveA)
|
||||||
.directive('ng1B', () => ng1DirectiveB)
|
.directive('ng1B', () => ng1DirectiveB)
|
||||||
.directive('ng2', downgradeComponent({component: Ng2Component}));
|
.directive('ng2', downgradeComponent({component: Ng2Component}));
|
||||||
@ -3389,7 +3405,8 @@ withEachNg1Version(() => {
|
|||||||
const element = html('<ng2 [show]="!destroyFromNg2" ng-if="!destroyFromNg1"></ng2>');
|
const element = html('<ng2 [show]="!destroyFromNg2" ng-if="!destroyFromNg1"></ng2>');
|
||||||
|
|
||||||
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then(adapter => {
|
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then(adapter => {
|
||||||
const $rootScope = adapter.$injector.get('$rootScope') as angular.IRootScopeService;
|
const $rootScope =
|
||||||
|
adapter.$injector.get('$rootScope') as angular.IRootScopeService;
|
||||||
|
|
||||||
expect(multiTrim(document.body.textContent)).toBe('ng1A | ng1B');
|
expect(multiTrim(document.body.textContent)).toBe('ng1A | ng1B');
|
||||||
expect(controllerOnDestroyA).not.toHaveBeenCalled();
|
expect(controllerOnDestroyA).not.toHaveBeenCalled();
|
||||||
@ -3948,6 +3965,7 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
fixmeIvy('FW-642: ASSERTION ERROR: Slot should have been initialized to NO_CHANGE') &&
|
||||||
it('should support ng2 > ng1 > ng2 (with inputs/outputs)', fakeAsync(() => {
|
it('should support ng2 > ng1 > ng2 (with inputs/outputs)', fakeAsync(() => {
|
||||||
let ng2ComponentAInstance: Ng2ComponentA;
|
let ng2ComponentAInstance: Ng2ComponentA;
|
||||||
let ng2ComponentBInstance: Ng2ComponentB;
|
let ng2ComponentBInstance: Ng2ComponentB;
|
||||||
@ -4032,7 +4050,8 @@ withEachNg1Version(() => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module = angular.module('ng1', [])
|
const ng1Module =
|
||||||
|
angular.module('ng1', [])
|
||||||
.component('ng1X', ng1Component)
|
.component('ng1X', ng1Component)
|
||||||
.directive('ng2A', downgradeComponent({component: Ng2ComponentA}))
|
.directive('ng2A', downgradeComponent({component: Ng2ComponentA}))
|
||||||
.directive('ng2B', downgradeComponent({component: Ng2ComponentB}));
|
.directive('ng2B', downgradeComponent({component: Ng2ComponentB}));
|
||||||
@ -4106,7 +4125,8 @@ withEachNg1Version(() => {
|
|||||||
.toBe('ng2A(foo, bar, baz6) | ng1X(foo4, bar4, baz6) | ng2B(foo4, baz6)');
|
.toBe('ng2A(foo, bar, baz6) | ng1X(foo4, bar4, baz6) | ng2B(foo4, baz6)');
|
||||||
|
|
||||||
// Emit from `ng1XOutputA`.
|
// Emit from `ng1XOutputA`.
|
||||||
// (Should propagate upwards to `ng1ADataA` and back all the way down to `ng2BInputA`.)
|
// (Should propagate upwards to `ng1ADataA` and back all the way down to
|
||||||
|
// `ng2BInputA`.)
|
||||||
(ng1ControllerXInstance as any).ng1XOutputA({value: 'foo7'});
|
(ng1ControllerXInstance as any).ng1XOutputA({value: 'foo7'});
|
||||||
$digest(adapter);
|
$digest(adapter);
|
||||||
tick();
|
tick();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user