parent
1c93afe956
commit
b04bc5d06c
|
@ -170,8 +170,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', []);
|
||||||
const log: string[] = [];
|
const log: string[] = [];
|
||||||
|
@ -197,9 +196,8 @@ 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 {
|
||||||
|
@ -826,8 +824,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;
|
||||||
|
|
||||||
|
@ -853,8 +850,7 @@ withEachNg1Version(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module =
|
const ng1Module = angular.module('ng1Module', [])
|
||||||
angular.module('ng1Module', [])
|
|
||||||
.component('ng1', ng1Component)
|
.component('ng1', ng1Component)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
|
@ -873,15 +869,13 @@ 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))
|
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
||||||
.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))
|
expect(multiTrim(element.textContent)).toBe('Inside: baz, qux | Outside: foo, bar');
|
||||||
.toBe('Inside: baz, qux | Outside: foo, bar');
|
|
||||||
|
|
||||||
ng2ComponentInstance.dataA = 'foo2';
|
ng2ComponentInstance.dataA = 'foo2';
|
||||||
ng2ComponentInstance.dataB = 'bar2';
|
ng2ComponentInstance.dataB = 'bar2';
|
||||||
|
@ -894,8 +888,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;
|
||||||
|
|
||||||
|
@ -921,8 +914,7 @@ withEachNg1Version(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module =
|
const ng1Module = angular.module('ng1Module', [])
|
||||||
angular.module('ng1Module', [])
|
|
||||||
.component('ng1', ng1Component)
|
.component('ng1', ng1Component)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
|
@ -941,15 +933,13 @@ 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))
|
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
||||||
.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))
|
expect(multiTrim(element.textContent)).toBe('Inside: baz, qux | Outside: foo, bar');
|
||||||
.toBe('Inside: baz, qux | Outside: foo, bar');
|
|
||||||
|
|
||||||
ng2ComponentInstance.dataA = {value: 'foo2'};
|
ng2ComponentInstance.dataA = {value: 'foo2'};
|
||||||
ng2ComponentInstance.dataB = {value: 'bar2'};
|
ng2ComponentInstance.dataB = {value: 'bar2'};
|
||||||
|
@ -962,8 +952,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;
|
||||||
|
|
||||||
|
@ -989,8 +978,7 @@ withEachNg1Version(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `ng1Module`
|
// Define `ng1Module`
|
||||||
const ng1Module =
|
const ng1Module = angular.module('ng1Module', [])
|
||||||
angular.module('ng1Module', [])
|
|
||||||
.component('ng1', ng1Component)
|
.component('ng1', ng1Component)
|
||||||
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
|
||||||
|
|
||||||
|
@ -1009,15 +997,13 @@ 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))
|
expect(multiTrim(element.textContent)).toBe('Inside: foo, bar | Outside: foo, bar');
|
||||||
.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))
|
expect(multiTrim(element.textContent)).toBe('Inside: baz, qux | Outside: baz, qux');
|
||||||
.toBe('Inside: baz, qux | Outside: baz, qux');
|
|
||||||
|
|
||||||
ng2ComponentInstance.dataA = {value: 'foo2'};
|
ng2ComponentInstance.dataA = {value: 'foo2'};
|
||||||
ng2ComponentInstance.dataB = {value: 'bar2'};
|
ng2ComponentInstance.dataB = {value: 'bar2'};
|
||||||
|
@ -1084,21 +1070,14 @@ 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', []);
|
||||||
|
|
||||||
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: {
|
scope: {fullName: '@', modelA: '=dataA', modelB: '=dataB', modelC: '=', event: '&'},
|
||||||
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') {
|
||||||
|
@ -1149,8 +1128,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', []);
|
||||||
|
|
||||||
|
@ -1194,8 +1172,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));
|
||||||
const ng1Module = angular.module('ng1', []);
|
const ng1Module = angular.module('ng1', []);
|
||||||
|
@ -1205,9 +1182,7 @@ withEachNg1Version(() => {
|
||||||
restrict: 'E',
|
restrict: 'E',
|
||||||
template: '{{someText}} - Length: {{data.length}}',
|
template: '{{someText}} - Length: {{data.length}}',
|
||||||
scope: {data: '='},
|
scope: {data: '='},
|
||||||
controller: function($scope: any) {
|
controller: function($scope: any) { $scope.someText = 'ng1 - Data: ' + $scope.data; }
|
||||||
$scope.someText = 'ng1 - Data: ' + $scope.data;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1242,8 +1217,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', []);
|
||||||
|
|
||||||
|
@ -1468,8 +1442,7 @@ withEachNg1Version(() => {
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
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', []);
|
||||||
|
|
||||||
|
@ -1503,8 +1476,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', []);
|
||||||
|
|
||||||
|
|
|
@ -2134,8 +2134,7 @@ withEachNg1Version(() => {
|
||||||
});
|
});
|
||||||
|
|
||||||
describe('transclusion', () => {
|
describe('transclusion', () => {
|
||||||
fixmeIvy(
|
fixmeIvy(`FW-863: Error: Failed to execute 'insertBefore' on 'Node'`)
|
||||||
`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;
|
||||||
|
@ -2531,8 +2530,7 @@ withEachNg1Version(() => {
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
fixmeIvy(
|
fixmeIvy(`FW-863: Error: Failed to execute 'insertBefore' on 'Node'`)
|
||||||
`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;
|
||||||
|
|
||||||
|
@ -3336,9 +3334,7 @@ withEachNg1Version(() => {
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
fixmeIvy(
|
it('should call `$onDestroy()` on controller', async(() => {
|
||||||
'FW-843: destroy hooks are not registered on upgraded ng1 components contained in ng2 component templates under ivy')
|
|
||||||
.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');
|
||||||
|
|
||||||
|
@ -3356,9 +3352,8 @@ withEachNg1Version(() => {
|
||||||
scope: {},
|
scope: {},
|
||||||
bindToController: true,
|
bindToController: true,
|
||||||
controllerAs: '$ctrl',
|
controllerAs: '$ctrl',
|
||||||
controller: class {
|
controller:
|
||||||
constructor() { (this as any)['$onDestroy'] = controllerOnDestroyB; }
|
class {constructor() { (this as any)['$onDestroy'] = controllerOnDestroyB; }}
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// Define `Ng1ComponentFacade`
|
// Define `Ng1ComponentFacade`
|
||||||
|
@ -3377,18 +3372,15 @@ withEachNg1Version(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define `Ng2Component`
|
// Define `Ng2Component`
|
||||||
@Component({
|
@Component(
|
||||||
selector: 'ng2',
|
{selector: 'ng2', template: '<div *ngIf="show"><ng1A></ng1A> | <ng1B></ng1B></div>'})
|
||||||
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 =
|
const ng1Module = angular.module('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}));
|
||||||
|
@ -3404,12 +3396,10 @@ withEachNg1Version(() => {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Bootstrap
|
// Bootstrap
|
||||||
const element =
|
const element = html('<ng2 [show]="!destroyFromNg2" ng-if="!destroyFromNg1"></ng2>');
|
||||||
html('<ng2 [show]="!destroyFromNg2" ng-if="!destroyFromNg1"></ng2>');
|
|
||||||
|
|
||||||
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then(adapter => {
|
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then(adapter => {
|
||||||
const $rootScope =
|
const $rootScope = adapter.$injector.get('$rootScope') as angular.IRootScopeService;
|
||||||
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();
|
||||||
|
@ -3968,7 +3958,6 @@ withEachNg1Version(() => {
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
// fixmeIvy('FW-724: upgraded ng1 components are not being rendered')
|
|
||||||
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;
|
||||||
|
|
Loading…
Reference in New Issue