test(ivy): re-enable passing tests and misc cleanup (#28093)
PR Close #28093
This commit is contained in:
parent
978ffa9d32
commit
6fff74e576
@ -168,21 +168,20 @@ describe('ngInjectableDef Bazel Integration', () => {
|
|||||||
expect(TestBed.get(INJECTOR).get('foo')).toEqual('bar');
|
expect(TestBed.get(INJECTOR).get('foo')).toEqual('bar');
|
||||||
});
|
});
|
||||||
|
|
||||||
fixmeIvy('FW-854: NodeInjector does not know how to get itself (INJECTOR)')
|
it('Component injector understands requests for INJECTABLE', () => {
|
||||||
.it('Component injector understands requests for INJECTABLE', () => {
|
@Component({
|
||||||
@Component({
|
selector: 'test-cmp',
|
||||||
selector: 'test-cmp',
|
template: 'test',
|
||||||
template: 'test',
|
providers: [{provide: 'foo', useValue: 'bar'}],
|
||||||
providers: [{provide: 'foo', useValue: 'bar'}],
|
})
|
||||||
})
|
class TestCmp {
|
||||||
class TestCmp {
|
}
|
||||||
}
|
|
||||||
|
|
||||||
TestBed.configureTestingModule({
|
TestBed.configureTestingModule({
|
||||||
declarations: [TestCmp],
|
declarations: [TestCmp],
|
||||||
});
|
});
|
||||||
|
|
||||||
const fixture = TestBed.createComponent(TestCmp);
|
const fixture = TestBed.createComponent(TestCmp);
|
||||||
expect(fixture.componentRef.injector.get(INJECTOR).get('foo')).toEqual('bar');
|
expect(fixture.componentRef.injector.get(INJECTOR).get('foo')).toEqual('bar');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -12,7 +12,6 @@ import {ChangeDetectionStrategy, Component, Injectable, NgModule, NgModuleFactor
|
|||||||
import {ComponentFixture, TestBed, fakeAsync, inject, tick} from '@angular/core/testing';
|
import {ComponentFixture, TestBed, fakeAsync, inject, tick} from '@angular/core/testing';
|
||||||
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
import {By} from '@angular/platform-browser/src/dom/debug/by';
|
||||||
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
import {expect} from '@angular/platform-browser/testing/src/matchers';
|
||||||
import {fixmeIvy} from '@angular/private/testing';
|
|
||||||
import {ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, CanActivate, CanDeactivate, ChildActivationEnd, ChildActivationStart, DetachedRouteHandle, Event, GuardsCheckEnd, GuardsCheckStart, Navigation, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, PRIMARY_OUTLET, ParamMap, Params, PreloadAllModules, PreloadingStrategy, Resolve, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterModule, RouterPreloader, RouterStateSnapshot, RoutesRecognized, RunGuardsAndResolvers, UrlHandlingStrategy, UrlSegmentGroup, UrlSerializer, UrlTree} from '@angular/router';
|
import {ActivatedRoute, ActivatedRouteSnapshot, ActivationEnd, ActivationStart, CanActivate, CanDeactivate, ChildActivationEnd, ChildActivationStart, DetachedRouteHandle, Event, GuardsCheckEnd, GuardsCheckStart, Navigation, NavigationCancel, NavigationEnd, NavigationError, NavigationStart, PRIMARY_OUTLET, ParamMap, Params, PreloadAllModules, PreloadingStrategy, Resolve, ResolveEnd, ResolveStart, RouteConfigLoadEnd, RouteConfigLoadStart, RouteReuseStrategy, Router, RouterEvent, RouterModule, RouterPreloader, RouterStateSnapshot, RoutesRecognized, RunGuardsAndResolvers, UrlHandlingStrategy, UrlSegmentGroup, UrlSerializer, UrlTree} from '@angular/router';
|
||||||
import {Observable, Observer, Subscription, of } from 'rxjs';
|
import {Observable, Observer, Subscription, of } from 'rxjs';
|
||||||
import {filter, first, map, tap} from 'rxjs/operators';
|
import {filter, first, map, tap} from 'rxjs/operators';
|
||||||
|
@ -169,53 +169,50 @@ withEachNg1Version(() => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('scope/component change-detection', () => {
|
describe('scope/component change-detection', () => {
|
||||||
fixmeIvy(
|
it('should interleave scope and component expressions', async(() => {
|
||||||
'FW-918: Create API and mental model to work with Host Element; and ChangeDetections')
|
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
||||||
.it('should interleave scope and component expressions', async(() => {
|
const ng1Module = angular.module('ng1', []);
|
||||||
const adapter: UpgradeAdapter = new UpgradeAdapter(forwardRef(() => Ng2Module));
|
const log: string[] = [];
|
||||||
const ng1Module = angular.module('ng1', []);
|
const l = (value: string) => {
|
||||||
const log: string[] = [];
|
log.push(value);
|
||||||
const l = (value: string) => {
|
return value + ';';
|
||||||
log.push(value);
|
};
|
||||||
return value + ';';
|
|
||||||
};
|
|
||||||
|
|
||||||
ng1Module.directive('ng1a', () => ({template: '{{ l(\'ng1a\') }}'}));
|
ng1Module.directive('ng1a', () => ({template: '{{ l(\'ng1a\') }}'}));
|
||||||
ng1Module.directive('ng1b', () => ({template: '{{ l(\'ng1b\') }}'}));
|
ng1Module.directive('ng1b', () => ({template: '{{ l(\'ng1b\') }}'}));
|
||||||
ng1Module.run(($rootScope: any) => {
|
ng1Module.run(($rootScope: any) => {
|
||||||
$rootScope.l = l;
|
$rootScope.l = l;
|
||||||
$rootScope.reset = () => log.length = 0;
|
$rootScope.reset = () => log.length = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ng2',
|
selector: 'ng2',
|
||||||
template: `{{l('2A')}}<ng1a></ng1a>{{l('2B')}}<ng1b></ng1b>{{l('2C')}}`
|
template: `{{l('2A')}}<ng1a></ng1a>{{l('2B')}}<ng1b></ng1b>{{l('2C')}}`
|
||||||
})
|
})
|
||||||
class Ng2 {
|
class Ng2 {
|
||||||
l: any;
|
l: any;
|
||||||
constructor() { this.l = l; }
|
constructor() { this.l = l; }
|
||||||
}
|
}
|
||||||
|
|
||||||
@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 {
|
}
|
||||||
}
|
|
||||||
|
|
||||||
ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2));
|
ng1Module.directive('ng2', adapter.downgradeNg2Component(Ng2));
|
||||||
|
|
||||||
const element =
|
const element =
|
||||||
html('<div>{{reset(); l(\'1A\');}}<ng2>{{l(\'1B\')}}</ng2>{{l(\'1C\')}}</div>');
|
html('<div>{{reset(); l(\'1A\');}}<ng2>{{l(\'1B\')}}</ng2>{{l(\'1C\')}}</div>');
|
||||||
adapter.bootstrap(element, ['ng1']).ready((ref) => {
|
adapter.bootstrap(element, ['ng1']).ready((ref) => {
|
||||||
expect(document.body.textContent).toEqual('1A;2A;ng1a;2B;ng1b;2C;1C;');
|
expect(document.body.textContent).toEqual('1A;2A;ng1a;2B;ng1b;2C;1C;');
|
||||||
// https://github.com/angular/angular.js/issues/12983
|
// https://github.com/angular/angular.js/issues/12983
|
||||||
expect(log).toEqual(['1A', '1C', '2A', '2B', '2C', 'ng1a', 'ng1b']);
|
expect(log).toEqual(['1A', '1C', '2A', '2B', '2C', 'ng1a', 'ng1b']);
|
||||||
ref.dispose();
|
ref.dispose();
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
|
|
||||||
it('should propagate changes to a downgraded component inside the ngZone', async(() => {
|
it('should propagate changes to a downgraded component inside the ngZone', async(() => {
|
||||||
|
@ -21,61 +21,60 @@ withEachNg1Version(() => {
|
|||||||
beforeEach(() => destroyPlatform());
|
beforeEach(() => destroyPlatform());
|
||||||
afterEach(() => destroyPlatform());
|
afterEach(() => destroyPlatform());
|
||||||
|
|
||||||
fixmeIvy('FW-918: Create API and mental model to work with Host Element; and ChangeDetections')
|
it('should interleave scope and component expressions', async(() => {
|
||||||
.it('should interleave scope and component expressions', async(() => {
|
const log: string[] = [];
|
||||||
const log: string[] = [];
|
const l = (value: string) => {
|
||||||
const l = (value: string) => {
|
log.push(value);
|
||||||
log.push(value);
|
return value + ';';
|
||||||
return value + ';';
|
};
|
||||||
};
|
|
||||||
|
|
||||||
@Directive({selector: 'ng1a'})
|
@Directive({selector: 'ng1a'})
|
||||||
class Ng1aComponent extends UpgradeComponent {
|
class Ng1aComponent extends UpgradeComponent {
|
||||||
constructor(elementRef: ElementRef, injector: Injector) {
|
constructor(elementRef: ElementRef, injector: Injector) {
|
||||||
super('ng1a', elementRef, injector);
|
super('ng1a', elementRef, injector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Directive({selector: 'ng1b'})
|
@Directive({selector: 'ng1b'})
|
||||||
class Ng1bComponent extends UpgradeComponent {
|
class Ng1bComponent extends UpgradeComponent {
|
||||||
constructor(elementRef: ElementRef, injector: Injector) {
|
constructor(elementRef: ElementRef, injector: Injector) {
|
||||||
super('ng1b', elementRef, injector);
|
super('ng1b', elementRef, injector);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Component({
|
@Component({
|
||||||
selector: 'ng2',
|
selector: 'ng2',
|
||||||
template: `{{l('2A')}}<ng1a></ng1a>{{l('2B')}}<ng1b></ng1b>{{l('2C')}}`
|
template: `{{l('2A')}}<ng1a></ng1a>{{l('2B')}}<ng1b></ng1b>{{l('2C')}}`
|
||||||
})
|
})
|
||||||
class Ng2Component {
|
class Ng2Component {
|
||||||
l = l;
|
l = l;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NgModule({
|
@NgModule({
|
||||||
declarations: [Ng1aComponent, Ng1bComponent, Ng2Component],
|
declarations: [Ng1aComponent, Ng1bComponent, Ng2Component],
|
||||||
entryComponents: [Ng2Component],
|
entryComponents: [Ng2Component],
|
||||||
imports: [BrowserModule, UpgradeModule]
|
imports: [BrowserModule, UpgradeModule]
|
||||||
})
|
})
|
||||||
class Ng2Module {
|
class Ng2Module {
|
||||||
ngDoBootstrap() {}
|
ngDoBootstrap() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
const ng1Module = angular.module('ng1', [])
|
const ng1Module = angular.module('ng1', [])
|
||||||
.directive('ng1a', () => ({template: '{{ l(\'ng1a\') }}'}))
|
.directive('ng1a', () => ({template: '{{ l(\'ng1a\') }}'}))
|
||||||
.directive('ng1b', () => ({template: '{{ l(\'ng1b\') }}'}))
|
.directive('ng1b', () => ({template: '{{ l(\'ng1b\') }}'}))
|
||||||
.directive('ng2', downgradeComponent({component: Ng2Component}))
|
.directive('ng2', downgradeComponent({component: Ng2Component}))
|
||||||
.run(($rootScope: angular.IRootScopeService) => {
|
.run(($rootScope: angular.IRootScopeService) => {
|
||||||
$rootScope.l = l;
|
$rootScope.l = l;
|
||||||
$rootScope.reset = () => log.length = 0;
|
$rootScope.reset = () => log.length = 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
const element =
|
const element =
|
||||||
html('<div>{{reset(); l(\'1A\');}}<ng2>{{l(\'1B\')}}</ng2>{{l(\'1C\')}}</div>');
|
html('<div>{{reset(); l(\'1A\');}}<ng2>{{l(\'1B\')}}</ng2>{{l(\'1C\')}}</div>');
|
||||||
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then((upgrade) => {
|
bootstrap(platformBrowserDynamic(), Ng2Module, element, ng1Module).then((upgrade) => {
|
||||||
expect(document.body.textContent).toEqual('1A;2A;ng1a;2B;ng1b;2C;1C;');
|
expect(document.body.textContent).toEqual('1A;2A;ng1a;2B;ng1b;2C;1C;');
|
||||||
expect(log).toEqual(['1A', '1C', '2A', '2B', '2C', 'ng1a', 'ng1b']);
|
expect(log).toEqual(['1A', '1C', '2A', '2B', '2C', 'ng1a', 'ng1b']);
|
||||||
});
|
});
|
||||||
}));
|
}));
|
||||||
|
|
||||||
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>');
|
const element = html('<my-app></my-app>');
|
||||||
|
Loading…
x
Reference in New Issue
Block a user