test(ivy): re-enable passing upgrade tests (#27736)

PR Close #27736
This commit is contained in:
Kara Erickson 2018-12-18 11:49:20 -08:00 committed by Miško Hevery
parent 1c93afe956
commit b04bc5d06c
2 changed files with 497 additions and 536 deletions

View File

@ -170,8 +170,7 @@ withEachNg1Version(() => {
});
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 ng1Module = angular.module('ng1', []);
const log: string[] = [];
@ -197,9 +196,8 @@ withEachNg1Version(() => {
}
@NgModule({
declarations: [
adapter.upgradeNg1Component('ng1a'), adapter.upgradeNg1Component('ng1b'), Ng2
],
declarations:
[adapter.upgradeNg1Component('ng1a'), adapter.upgradeNg1Component('ng1b'), Ng2],
imports: [BrowserModule],
})
class Ng2Module {
@ -826,8 +824,7 @@ withEachNg1Version(() => {
});
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));
let ng2ComponentInstance: Ng2Component;
@ -853,8 +850,7 @@ withEachNg1Version(() => {
}
// Define `ng1Module`
const ng1Module =
angular.module('ng1Module', [])
const ng1Module = angular.module('ng1Module', [])
.component('ng1', ng1Component)
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
@ -873,15 +869,13 @@ withEachNg1Version(() => {
const ng1 = element.querySelector('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.inputB = 'qux';
$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.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));
let ng2ComponentInstance: Ng2Component;
@ -921,8 +914,7 @@ withEachNg1Version(() => {
}
// Define `ng1Module`
const ng1Module =
angular.module('ng1Module', [])
const ng1Module = angular.module('ng1Module', [])
.component('ng1', ng1Component)
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
@ -941,15 +933,13 @@ withEachNg1Version(() => {
const ng1 = element.querySelector('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.inputB = {value: 'qux'};
$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.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));
let ng2ComponentInstance: Ng2Component;
@ -989,8 +978,7 @@ withEachNg1Version(() => {
}
// Define `ng1Module`
const ng1Module =
angular.module('ng1Module', [])
const ng1Module = angular.module('ng1Module', [])
.component('ng1', ng1Component)
.directive('ng2', adapter.downgradeNg2Component(Ng2Component));
@ -1009,15 +997,13 @@ withEachNg1Version(() => {
const ng1 = element.querySelector('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.inputB = {value: 'qux'};
$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.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 ng1Module = angular.module('ng1', []);
const ng1 = () => {
return {
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) {
scope.$watch('modelB', (v: string) => {
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 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(() => {
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
const ng1Module = angular.module('ng1', []);
@ -1205,9 +1182,7 @@ withEachNg1Version(() => {
restrict: 'E',
template: '{{someText}} - Length: {{data.length}}',
scope: {data: '='},
controller: function($scope: any) {
$scope.someText = 'ng1 - Data: ' + $scope.data;
}
controller: function($scope: any) { $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 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 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 ng1Module = angular.module('ng1', []);

View File

@ -2134,8 +2134,7 @@ withEachNg1Version(() => {
});
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.`)
fixmeIvy(`FW-863: Error: Failed to execute 'insertBefore' on 'Node'`)
.it('should support single-slot transclusion', async(() => {
let ng2ComponentAInstance: Ng2ComponentA;
let ng2ComponentBInstance: Ng2ComponentB;
@ -2531,8 +2530,7 @@ 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.`)
fixmeIvy(`FW-863: Error: Failed to execute 'insertBefore' on 'Node'`)
.it('should support structural directives in transcluded content', async(() => {
let ng2ComponentInstance: Ng2Component;
@ -3336,9 +3334,7 @@ withEachNg1Version(() => {
}));
fixmeIvy(
'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(() => {
it('should call `$onDestroy()` on controller', async(() => {
const controllerOnDestroyA = jasmine.createSpy('controllerOnDestroyA');
const controllerOnDestroyB = jasmine.createSpy('controllerOnDestroyB');
@ -3356,9 +3352,8 @@ withEachNg1Version(() => {
scope: {},
bindToController: true,
controllerAs: '$ctrl',
controller: class {
constructor() { (this as any)['$onDestroy'] = controllerOnDestroyB; }
}
controller:
class {constructor() { (this as any)['$onDestroy'] = controllerOnDestroyB; }}
};
// Define `Ng1ComponentFacade`
@ -3377,18 +3372,15 @@ withEachNg1Version(() => {
}
// Define `Ng2Component`
@Component({
selector: 'ng2',
template: '<div *ngIf="show"><ng1A></ng1A> | <ng1B></ng1B></div>'
})
@Component(
{selector: 'ng2', template: '<div *ngIf="show"><ng1A></ng1A> | <ng1B></ng1B></div>'})
class Ng2Component {
// TODO(issue/24571): remove '!'.
@Input() show !: boolean;
}
// Define `ng1Module`
const ng1Module =
angular.module('ng1Module', [])
const ng1Module = angular.module('ng1Module', [])
.directive('ng1A', () => ng1DirectiveA)
.directive('ng1B', () => ng1DirectiveB)
.directive('ng2', downgradeComponent({component: Ng2Component}));
@ -3404,12 +3396,10 @@ withEachNg1Version(() => {
}
// Bootstrap
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 => {
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(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(() => {
let ng2ComponentAInstance: Ng2ComponentA;
let ng2ComponentBInstance: Ng2ComponentB;