test(ivy): add ability to find already passing tests (#27449)
PR Close #27449
This commit is contained in:
@ -35,26 +35,26 @@ ivyEnabled && describe('ApplicationRef bootstrap', () => {
|
||||
class MyAppModule {
|
||||
}
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should bootstrap hello world', withBody('<hello-world></hello-world>', async() => {
|
||||
const MyAppModuleFactory = new NgModuleFactory(MyAppModule);
|
||||
const moduleRef = await getTestBed().platform.bootstrapModuleFactory(
|
||||
MyAppModuleFactory, {ngZone: 'noop'});
|
||||
const appRef = moduleRef.injector.get(ApplicationRef);
|
||||
const helloWorldComponent = appRef.components[0].instance as HelloWorldComponent;
|
||||
expect(document.body.innerHTML)
|
||||
.toEqual('<hello-world><div>Hello World</div></hello-world>');
|
||||
expect(helloWorldComponent.log).toEqual(['OnInit', 'DoCheck']);
|
||||
fixmeIvy('unknown').it(
|
||||
'should bootstrap hello world', withBody('<hello-world></hello-world>', async() => {
|
||||
const MyAppModuleFactory = new NgModuleFactory(MyAppModule);
|
||||
const moduleRef = await getTestBed().platform.bootstrapModuleFactory(
|
||||
MyAppModuleFactory, {ngZone: 'noop'});
|
||||
const appRef = moduleRef.injector.get(ApplicationRef);
|
||||
const helloWorldComponent = appRef.components[0].instance as HelloWorldComponent;
|
||||
expect(document.body.innerHTML)
|
||||
.toEqual('<hello-world><div>Hello World</div></hello-world>');
|
||||
expect(helloWorldComponent.log).toEqual(['OnInit', 'DoCheck']);
|
||||
|
||||
helloWorldComponent.name = 'Mundo';
|
||||
appRef.tick();
|
||||
expect(document.body.innerHTML)
|
||||
.toEqual('<hello-world><div>Hello Mundo</div></hello-world>');
|
||||
expect(helloWorldComponent.log).toEqual(['OnInit', 'DoCheck', 'DoCheck']);
|
||||
helloWorldComponent.name = 'Mundo';
|
||||
appRef.tick();
|
||||
expect(document.body.innerHTML)
|
||||
.toEqual('<hello-world><div>Hello Mundo</div></hello-world>');
|
||||
expect(helloWorldComponent.log).toEqual(['OnInit', 'DoCheck', 'DoCheck']);
|
||||
|
||||
// Cleanup TestabilityRegistry
|
||||
const registry: TestabilityRegistry = getTestBed().get(TestabilityRegistry);
|
||||
registry.unregisterAllApplications();
|
||||
}));
|
||||
// Cleanup TestabilityRegistry
|
||||
const registry: TestabilityRegistry = getTestBed().get(TestabilityRegistry);
|
||||
registry.unregisterAllApplications();
|
||||
}));
|
||||
|
||||
});
|
||||
|
@ -74,63 +74,63 @@ class SomeComponent {
|
||||
return MyModule;
|
||||
}
|
||||
|
||||
fixmeIvy('FW-776: Cannot bootstrap as there are still asynchronous initializers running') &&
|
||||
it('should bootstrap a component from a child module',
|
||||
async(inject([ApplicationRef, Compiler], (app: ApplicationRef, compiler: Compiler) => {
|
||||
@Component({
|
||||
selector: 'bootstrap-app',
|
||||
template: '',
|
||||
})
|
||||
class SomeComponent {
|
||||
}
|
||||
fixmeIvy('FW-776: Cannot bootstrap as there are still asynchronous initializers running')
|
||||
.it('should bootstrap a component from a child module',
|
||||
async(inject([ApplicationRef, Compiler], (app: ApplicationRef, compiler: Compiler) => {
|
||||
@Component({
|
||||
selector: 'bootstrap-app',
|
||||
template: '',
|
||||
})
|
||||
class SomeComponent {
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
providers: [{provide: 'hello', useValue: 'component'}],
|
||||
declarations: [SomeComponent],
|
||||
entryComponents: [SomeComponent],
|
||||
})
|
||||
class SomeModule {
|
||||
}
|
||||
@NgModule({
|
||||
providers: [{provide: 'hello', useValue: 'component'}],
|
||||
declarations: [SomeComponent],
|
||||
entryComponents: [SomeComponent],
|
||||
})
|
||||
class SomeModule {
|
||||
}
|
||||
|
||||
createRootEl();
|
||||
const modFactory = compiler.compileModuleSync(SomeModule);
|
||||
const module = modFactory.create(TestBed);
|
||||
const cmpFactory =
|
||||
module.componentFactoryResolver.resolveComponentFactory(SomeComponent) !;
|
||||
const component = app.bootstrap(cmpFactory);
|
||||
createRootEl();
|
||||
const modFactory = compiler.compileModuleSync(SomeModule);
|
||||
const module = modFactory.create(TestBed);
|
||||
const cmpFactory =
|
||||
module.componentFactoryResolver.resolveComponentFactory(SomeComponent) !;
|
||||
const component = app.bootstrap(cmpFactory);
|
||||
|
||||
// The component should see the child module providers
|
||||
expect(component.injector.get('hello')).toEqual('component');
|
||||
})));
|
||||
// The component should see the child module providers
|
||||
expect(component.injector.get('hello')).toEqual('component');
|
||||
})));
|
||||
|
||||
fixmeIvy('FW-776: Cannot bootstrap as there are still asynchronous initializers running') &&
|
||||
it('should bootstrap a component with a custom selector',
|
||||
async(inject([ApplicationRef, Compiler], (app: ApplicationRef, compiler: Compiler) => {
|
||||
@Component({
|
||||
selector: 'bootstrap-app',
|
||||
template: '',
|
||||
})
|
||||
class SomeComponent {
|
||||
}
|
||||
fixmeIvy('FW-776: Cannot bootstrap as there are still asynchronous initializers running')
|
||||
.it('should bootstrap a component with a custom selector',
|
||||
async(inject([ApplicationRef, Compiler], (app: ApplicationRef, compiler: Compiler) => {
|
||||
@Component({
|
||||
selector: 'bootstrap-app',
|
||||
template: '',
|
||||
})
|
||||
class SomeComponent {
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
providers: [{provide: 'hello', useValue: 'component'}],
|
||||
declarations: [SomeComponent],
|
||||
entryComponents: [SomeComponent],
|
||||
})
|
||||
class SomeModule {
|
||||
}
|
||||
@NgModule({
|
||||
providers: [{provide: 'hello', useValue: 'component'}],
|
||||
declarations: [SomeComponent],
|
||||
entryComponents: [SomeComponent],
|
||||
})
|
||||
class SomeModule {
|
||||
}
|
||||
|
||||
createRootEl('custom-selector');
|
||||
const modFactory = compiler.compileModuleSync(SomeModule);
|
||||
const module = modFactory.create(TestBed);
|
||||
const cmpFactory =
|
||||
module.componentFactoryResolver.resolveComponentFactory(SomeComponent) !;
|
||||
const component = app.bootstrap(cmpFactory, 'custom-selector');
|
||||
createRootEl('custom-selector');
|
||||
const modFactory = compiler.compileModuleSync(SomeModule);
|
||||
const module = modFactory.create(TestBed);
|
||||
const cmpFactory =
|
||||
module.componentFactoryResolver.resolveComponentFactory(SomeComponent) !;
|
||||
const component = app.bootstrap(cmpFactory, 'custom-selector');
|
||||
|
||||
// The component should see the child module providers
|
||||
expect(component.injector.get('hello')).toEqual('component');
|
||||
})));
|
||||
// The component should see the child module providers
|
||||
expect(component.injector.get('hello')).toEqual('component');
|
||||
})));
|
||||
|
||||
describe('ApplicationRef', () => {
|
||||
beforeEach(() => { TestBed.configureTestingModule({imports: [createModule()]}); });
|
||||
|
@ -33,10 +33,10 @@ const ProxyZoneSpec: {assertPresent: () => void} = (Zone as any)['ProxyZoneSpec'
|
||||
})('foo', 'bar');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should work with inject()',
|
||||
fakeAsync(inject([Parser], (parser: any /** TODO #9100 */) => {
|
||||
expect(parser).toBeAnInstanceOf(Parser);
|
||||
})));
|
||||
fixmeIvy('unknown').it(
|
||||
'should work with inject()', fakeAsync(inject([Parser], (parser: any /** TODO #9100 */) => {
|
||||
expect(parser).toBeAnInstanceOf(Parser);
|
||||
})));
|
||||
|
||||
it('should throw on nested calls', () => {
|
||||
expect(() => {
|
||||
|
@ -15,8 +15,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
describe('forwardRef integration', function() {
|
||||
beforeEach(() => { TestBed.configureTestingModule({imports: [Module], declarations: [App]}); });
|
||||
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account') &&
|
||||
it('should instantiate components which are declared using forwardRef', () => {
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account')
|
||||
.it('should instantiate components which are declared using forwardRef', () => {
|
||||
const a =
|
||||
TestBed.configureTestingModule({schemas: [NO_ERRORS_SCHEMA]}).createComponent(App);
|
||||
a.detectChanges();
|
||||
|
@ -69,21 +69,20 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(childComp.cfr.resolveComponentFactory(ChildComp) !.componentType).toBe(ChildComp);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should not be able to get components from a parent component (content hierarchy)',
|
||||
() => {
|
||||
TestBed.overrideComponent(
|
||||
MainComp, {set: {template: '<child><nested></nested></child>'}});
|
||||
TestBed.overrideComponent(ChildComp, {set: {template: '<ng-content></ng-content>'}});
|
||||
fixmeIvy('unknown').it(
|
||||
'should not be able to get components from a parent component (content hierarchy)', () => {
|
||||
TestBed.overrideComponent(
|
||||
MainComp, {set: {template: '<child><nested></nested></child>'}});
|
||||
TestBed.overrideComponent(ChildComp, {set: {template: '<ng-content></ng-content>'}});
|
||||
|
||||
const compFixture = TestBed.createComponent(MainComp);
|
||||
const nestedChildCompEl = compFixture.debugElement.children[0].children[0];
|
||||
const nestedChildComp: NestedChildComp = nestedChildCompEl.componentInstance;
|
||||
expect(nestedChildComp.cfr.resolveComponentFactory(ChildComp) !.componentType)
|
||||
.toBe(ChildComp);
|
||||
expect(() => nestedChildComp.cfr.resolveComponentFactory(NestedChildComp))
|
||||
.toThrow(noComponentFactoryError(NestedChildComp));
|
||||
});
|
||||
const compFixture = TestBed.createComponent(MainComp);
|
||||
const nestedChildCompEl = compFixture.debugElement.children[0].children[0];
|
||||
const nestedChildComp: NestedChildComp = nestedChildCompEl.componentInstance;
|
||||
expect(nestedChildComp.cfr.resolveComponentFactory(ChildComp) !.componentType)
|
||||
.toBe(ChildComp);
|
||||
expect(() => nestedChildComp.cfr.resolveComponentFactory(NestedChildComp))
|
||||
.toThrow(noComponentFactoryError(NestedChildComp));
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
@ -209,8 +209,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
.toEqual('Some other <div>HTML</div>');
|
||||
});
|
||||
|
||||
modifiedInIvy('Binding to the class property directly works differently') &&
|
||||
it('should consume binding to className using class alias', () => {
|
||||
modifiedInIvy('Binding to the class property directly works differently')
|
||||
.it('should consume binding to className using class alias', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp]});
|
||||
const template = '<div class="initial" [class]="ctxProp"></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
@ -238,8 +238,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(getDOM().getProperty(nativeEl, 'htmlFor')).toBe('foo');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-587: Inputs with aliases in component decorators don\'t work') &&
|
||||
it('should consume directive watch expression change.', () => {
|
||||
fixmeIvy('FW-587: Inputs with aliases in component decorators don\'t work')
|
||||
.it('should consume directive watch expression change.', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, MyDir]});
|
||||
const template = '<span>' +
|
||||
'<div my-dir [elprop]="ctxProp"></div>' +
|
||||
@ -263,8 +263,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
describe('pipes', () => {
|
||||
fixmeIvy('FW-587: Inputs with aliases in component decorators don\'t work') &&
|
||||
it('should support pipes in bindings', () => {
|
||||
fixmeIvy('FW-587: Inputs with aliases in component decorators don\'t work')
|
||||
.it('should support pipes in bindings', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, MyDir, DoublePipe]});
|
||||
const template = '<div my-dir #dir="mydir" [elprop]="ctxProp | double"></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
@ -290,8 +290,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
// GH issue 328 - https://github.com/angular/angular/issues/328
|
||||
fixmeIvy('FW-587: Inputs with aliases in component decorators don\'t work') &&
|
||||
it('should support different directive types on a single node', () => {
|
||||
fixmeIvy('FW-587: Inputs with aliases in component decorators don\'t work')
|
||||
.it('should support different directive types on a single node', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, ChildComp, MyDir]});
|
||||
const template = '<child-cmp my-dir [elprop]="ctxProp"></child-cmp>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
@ -350,8 +350,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(tc.injector.get(EventDir)).not.toBeNull();
|
||||
});
|
||||
|
||||
fixmeIvy('FW-680: Throw meaningful error for uninitialized @Output') &&
|
||||
it('should display correct error message for uninitialized @Output', () => {
|
||||
fixmeIvy('FW-680: Throw meaningful error for uninitialized @Output')
|
||||
.it('should display correct error message for uninitialized @Output', () => {
|
||||
@Component({selector: 'my-uninitialized-output', template: '<p>It works!</p>'})
|
||||
class UninitializedOutputComp {
|
||||
@Output() customEvent !: EventEmitter<any>;
|
||||
@ -374,8 +374,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
});
|
||||
|
||||
modifiedInIvy('Comment node order changed') &&
|
||||
it('should support template directives via `<ng-template>` elements.', () => {
|
||||
modifiedInIvy('Comment node order changed')
|
||||
.it('should support template directives via `<ng-template>` elements.', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, SomeViewport]});
|
||||
const template =
|
||||
'<ng-template some-viewport let-greeting="someTmpl"><span>{{greeting}}</span></ng-template>';
|
||||
@ -403,8 +403,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-665: Discovery util fails with "Unable to find the given context data for the given target"') &&
|
||||
it('should not detach views in ViewContainers when the parent view is destroyed.', () => {
|
||||
'FW-665: Discovery util fails with "Unable to find the given context data for the given target"')
|
||||
.it('should not detach views in ViewContainers when the parent view is destroyed.', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, SomeViewport]});
|
||||
const template =
|
||||
'<div *ngIf="ctxBoolProp"><ng-template some-viewport let-greeting="someTmpl"><span>{{greeting}}</span></ng-template></div>';
|
||||
@ -478,8 +478,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
.toBeAnInstanceOf(ExportDir);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-708: Directives with multiple exports are not supported') &&
|
||||
it('should assign a directive to a ref when it has multiple exportAs names', () => {
|
||||
fixmeIvy('FW-708: Directives with multiple exports are not supported')
|
||||
.it('should assign a directive to a ref when it has multiple exportAs names', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, DirectiveWithMultipleExportAsNames]});
|
||||
|
||||
@ -543,8 +543,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(value.tagName.toLowerCase()).toEqual('div');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-709: Context discovery does not support templates (comment nodes)') &&
|
||||
it('should assign the TemplateRef to a user-defined variable', () => {
|
||||
fixmeIvy('FW-709: Context discovery does not support templates (comment nodes)')
|
||||
.it('should assign the TemplateRef to a user-defined variable', () => {
|
||||
const fixture =
|
||||
TestBed.configureTestingModule({declarations: [MyComp]})
|
||||
.overrideComponent(
|
||||
@ -567,8 +567,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
describe('variables', () => {
|
||||
modifiedInIvy('Comment node order changed') &&
|
||||
it('should allow to use variables in a for loop', () => {
|
||||
modifiedInIvy('Comment node order changed')
|
||||
.it('should allow to use variables in a for loop', () => {
|
||||
const template =
|
||||
'<ng-template ngFor [ngForOf]="[1]" let-i><child-cmp-no-template #cmp></child-cmp-no-template>{{i}}-{{cmp.ctxProp}}</ng-template>';
|
||||
|
||||
@ -586,8 +586,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
describe('OnPush components', () => {
|
||||
|
||||
fixmeIvy(
|
||||
'FW-764: fixture.detectChanges() is not respecting OnPush flag on components in the root template') &&
|
||||
it('should use ChangeDetectorRef to manually request a check', () => {
|
||||
'FW-764: fixture.detectChanges() is not respecting OnPush flag on components in the root template')
|
||||
.it('should use ChangeDetectorRef to manually request a check', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithRef]]]});
|
||||
const template = '<push-cmp-with-ref #cmp></push-cmp-with-ref>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
@ -608,8 +608,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-764: fixture.detectChanges() is not respecting OnPush flag on components in the root template') &&
|
||||
it('should be checked when its bindings got updated', () => {
|
||||
'FW-764: fixture.detectChanges() is not respecting OnPush flag on components in the root template')
|
||||
.it('should be checked when its bindings got updated', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]});
|
||||
const template = '<push-cmp [prop]="ctxProp" #cmp></push-cmp>';
|
||||
@ -628,28 +628,27 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
if (getDOM().supportsDOMEvents()) {
|
||||
fixmeIvy('unknown') &&
|
||||
it('should allow to destroy a component from within a host event handler',
|
||||
fakeAsync(() => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, [[PushCmpWithHostEvent]]]});
|
||||
const template = '<push-cmp-with-host-event></push-cmp-with-host-event>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
fixmeIvy('unknown').it(
|
||||
'should allow to destroy a component from within a host event handler',
|
||||
fakeAsync(() => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithHostEvent]]]});
|
||||
const template = '<push-cmp-with-host-event></push-cmp-with-host-event>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
|
||||
const cmpEl = fixture.debugElement.children[0];
|
||||
const cmp: PushCmpWithHostEvent = cmpEl.injector.get(PushCmpWithHostEvent);
|
||||
cmp.ctxCallback = (_: any) => fixture.destroy();
|
||||
const cmpEl = fixture.debugElement.children[0];
|
||||
const cmp: PushCmpWithHostEvent = cmpEl.injector.get(PushCmpWithHostEvent);
|
||||
cmp.ctxCallback = (_: any) => fixture.destroy();
|
||||
|
||||
expect(() => cmpEl.triggerEventHandler('click', <Event>{})).not.toThrow();
|
||||
}));
|
||||
expect(() => cmpEl.triggerEventHandler('click', <Event>{})).not.toThrow();
|
||||
}));
|
||||
}
|
||||
|
||||
fixmeIvy('FW-758: OnPush events not marking view dirty when using renderer2') &&
|
||||
it('should be checked when an event is fired', () => {
|
||||
fixmeIvy('FW-758: OnPush events not marking view dirty when using renderer2')
|
||||
.it('should be checked when an event is fired', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]});
|
||||
const template = '<push-cmp [prop]="ctxProp" #cmp></push-cmp>';
|
||||
@ -774,71 +773,71 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-763: LView tree not properly constructed / destroyed for dynamically inserted components') &&
|
||||
it('should support events via EventEmitter on regular elements', async(() => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]});
|
||||
const template = '<div emitter listener></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
'FW-763: LView tree not properly constructed / destroyed for dynamically inserted components')
|
||||
.it('should support events via EventEmitter on regular elements', async(() => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]});
|
||||
const template = '<div emitter listener></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
|
||||
const tc = fixture.debugElement.children[0];
|
||||
const emitter = tc.injector.get(DirectiveEmittingEvent);
|
||||
const listener = tc.injector.get(DirectiveListeningEvent);
|
||||
const tc = fixture.debugElement.children[0];
|
||||
const emitter = tc.injector.get(DirectiveEmittingEvent);
|
||||
const listener = tc.injector.get(DirectiveListeningEvent);
|
||||
|
||||
expect(listener.msg).toEqual('');
|
||||
let eventCount = 0;
|
||||
expect(listener.msg).toEqual('');
|
||||
let eventCount = 0;
|
||||
|
||||
emitter.event.subscribe({
|
||||
next: () => {
|
||||
eventCount++;
|
||||
if (eventCount === 1) {
|
||||
expect(listener.msg).toEqual('fired !');
|
||||
fixture.destroy();
|
||||
emitter.fireEvent('fired again !');
|
||||
} else {
|
||||
expect(listener.msg).toEqual('fired !');
|
||||
}
|
||||
}
|
||||
});
|
||||
emitter.event.subscribe({
|
||||
next: () => {
|
||||
eventCount++;
|
||||
if (eventCount === 1) {
|
||||
expect(listener.msg).toEqual('fired !');
|
||||
fixture.destroy();
|
||||
emitter.fireEvent('fired again !');
|
||||
} else {
|
||||
expect(listener.msg).toEqual('fired !');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
emitter.fireEvent('fired !');
|
||||
}));
|
||||
emitter.fireEvent('fired !');
|
||||
}));
|
||||
|
||||
fixmeIvy(
|
||||
'FW-665: Discovery util fails with Unable to find the given context data for the given target') &&
|
||||
it('should support events via EventEmitter on template elements', async(() => {
|
||||
const fixture =
|
||||
TestBed
|
||||
.configureTestingModule({
|
||||
declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]
|
||||
})
|
||||
.overrideComponent(MyComp, {
|
||||
set: {
|
||||
template:
|
||||
'<ng-template emitter listener (event)="ctxProp=$event"></ng-template>'
|
||||
}
|
||||
})
|
||||
.createComponent(MyComp);
|
||||
'FW-665: Discovery util fails with Unable to find the given context data for the given target')
|
||||
.it('should support events via EventEmitter on template elements', async(() => {
|
||||
const fixture =
|
||||
TestBed
|
||||
.configureTestingModule({
|
||||
declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]
|
||||
})
|
||||
.overrideComponent(MyComp, {
|
||||
set: {
|
||||
template:
|
||||
'<ng-template emitter listener (event)="ctxProp=$event"></ng-template>'
|
||||
}
|
||||
})
|
||||
.createComponent(MyComp);
|
||||
|
||||
const tc = fixture.debugElement.childNodes[0];
|
||||
const tc = fixture.debugElement.childNodes[0];
|
||||
|
||||
const emitter = tc.injector.get(DirectiveEmittingEvent);
|
||||
const myComp = fixture.debugElement.injector.get(MyComp);
|
||||
const listener = tc.injector.get(DirectiveListeningEvent);
|
||||
const emitter = tc.injector.get(DirectiveEmittingEvent);
|
||||
const myComp = fixture.debugElement.injector.get(MyComp);
|
||||
const listener = tc.injector.get(DirectiveListeningEvent);
|
||||
|
||||
myComp.ctxProp = '';
|
||||
expect(listener.msg).toEqual('');
|
||||
myComp.ctxProp = '';
|
||||
expect(listener.msg).toEqual('');
|
||||
|
||||
emitter.event.subscribe({
|
||||
next: () => {
|
||||
expect(listener.msg).toEqual('fired !');
|
||||
expect(myComp.ctxProp).toEqual('fired !');
|
||||
}
|
||||
});
|
||||
emitter.event.subscribe({
|
||||
next: () => {
|
||||
expect(listener.msg).toEqual('fired !');
|
||||
expect(myComp.ctxProp).toEqual('fired !');
|
||||
}
|
||||
});
|
||||
|
||||
emitter.fireEvent('fired !');
|
||||
}));
|
||||
emitter.fireEvent('fired !');
|
||||
}));
|
||||
|
||||
it('should support [()] syntax', async(() => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, DirectiveWithTwoWayBinding]});
|
||||
@ -860,8 +859,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
}));
|
||||
|
||||
fixmeIvy(
|
||||
'FW-743: Registering events on global objects (document, window, body) is not supported') &&
|
||||
it('should support render events', () => {
|
||||
'FW-743: Registering events on global objects (document, window, body) is not supported')
|
||||
.it('should support render events', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, DirectiveListeningDomEvent]});
|
||||
const template = '<div listener></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
@ -883,8 +882,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-743: Registering events on global objects (document, window, body) is not supported') &&
|
||||
it('should support render global events', () => {
|
||||
'FW-743: Registering events on global objects (document, window, body) is not supported')
|
||||
.it('should support render global events', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, DirectiveListeningDomEvent]});
|
||||
const template = '<div listener></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
@ -947,8 +946,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(getDOM().getProperty(tc.nativeElement, 'id')).toEqual('newId');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-681: not possible to retrieve host property bindings from TView') &&
|
||||
it('should not use template variables for expressions in hostProperties', () => {
|
||||
fixmeIvy('FW-681: not possible to retrieve host property bindings from TView')
|
||||
.it('should not use template variables for expressions in hostProperties', () => {
|
||||
@Directive(
|
||||
{selector: '[host-properties]', host: {'[id]': 'id', '[title]': 'unknownProp'}})
|
||||
class DirectiveWithHostProps {
|
||||
@ -968,8 +967,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(tc.properties['title']).toBe(undefined);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-725: Pipes in host bindings fail with a cryptic error') &&
|
||||
it('should not allow pipes in hostProperties', () => {
|
||||
fixmeIvy('FW-725: Pipes in host bindings fail with a cryptic error')
|
||||
.it('should not allow pipes in hostProperties', () => {
|
||||
@Directive({selector: '[host-properties]', host: {'[id]': 'id | uppercase'}})
|
||||
class DirectiveWithHostProps {
|
||||
}
|
||||
@ -1004,8 +1003,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(dir.receivedArgs).toEqual(['one', undefined]);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-742: Pipes in host listeners should throw a descriptive error') &&
|
||||
it('should not allow pipes in hostListeners', () => {
|
||||
fixmeIvy('FW-742: Pipes in host listeners should throw a descriptive error')
|
||||
.it('should not allow pipes in hostListeners', () => {
|
||||
@Directive({selector: '[host-listener]', host: {'(click)': 'doIt() | somePipe'}})
|
||||
class DirectiveWithHostListener {
|
||||
}
|
||||
@ -1042,8 +1041,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
}
|
||||
|
||||
fixmeIvy(
|
||||
'FW-743: Registering events on global objects (document, window, body) is not supported') &&
|
||||
it('should support render global events from multiple directives', () => {
|
||||
'FW-743: Registering events on global objects (document, window, body) is not supported')
|
||||
.it('should support render global events from multiple directives', () => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [MyComp, DirectiveListeningDomEvent, DirectiveListeningDomEventOther]
|
||||
});
|
||||
@ -1123,8 +1122,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
.toHaveText('dynamic greet');
|
||||
}));
|
||||
|
||||
fixmeIvy('FW-707: TestBed: No LView in getParentInjectorLocation') &&
|
||||
it('should create a component that has been freshly compiled', () => {
|
||||
fixmeIvy('FW-707: TestBed: No LView in getParentInjectorLocation')
|
||||
.it('should create a component that has been freshly compiled', () => {
|
||||
@Component({template: ''})
|
||||
class RootComp {
|
||||
constructor(public vc: ViewContainerRef) {}
|
||||
@ -1163,8 +1162,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(compRef.instance.someToken).toBe('someRootValue');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-707: TestBed: No LView in getParentInjectorLocation') &&
|
||||
it('should create a component with the passed NgModuleRef', () => {
|
||||
fixmeIvy('FW-707: TestBed: No LView in getParentInjectorLocation')
|
||||
.it('should create a component with the passed NgModuleRef', () => {
|
||||
@Component({template: ''})
|
||||
class RootComp {
|
||||
constructor(public vc: ViewContainerRef) {}
|
||||
@ -1204,48 +1203,48 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(compRef.instance.someToken).toBe('someValue');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-707: TestBed: No LView in getParentInjectorLocation') &&
|
||||
it('should create a component with the NgModuleRef of the ComponentFactoryResolver',
|
||||
() => {
|
||||
@Component({template: ''})
|
||||
class RootComp {
|
||||
constructor(public vc: ViewContainerRef) {}
|
||||
}
|
||||
fixmeIvy('FW-707: TestBed: No LView in getParentInjectorLocation')
|
||||
.it('should create a component with the NgModuleRef of the ComponentFactoryResolver',
|
||||
() => {
|
||||
@Component({template: ''})
|
||||
class RootComp {
|
||||
constructor(public vc: ViewContainerRef) {}
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [RootComp],
|
||||
providers: [{provide: 'someToken', useValue: 'someRootValue'}],
|
||||
})
|
||||
class RootModule {
|
||||
}
|
||||
@NgModule({
|
||||
declarations: [RootComp],
|
||||
providers: [{provide: 'someToken', useValue: 'someRootValue'}],
|
||||
})
|
||||
class RootModule {
|
||||
}
|
||||
|
||||
@Component({template: ''})
|
||||
class MyComp {
|
||||
constructor(@Inject('someToken') public someToken: string) {}
|
||||
}
|
||||
@Component({template: ''})
|
||||
class MyComp {
|
||||
constructor(@Inject('someToken') public someToken: string) {}
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [MyComp],
|
||||
entryComponents: [MyComp],
|
||||
providers: [{provide: 'someToken', useValue: 'someValue'}],
|
||||
})
|
||||
class MyModule {
|
||||
}
|
||||
@NgModule({
|
||||
declarations: [MyComp],
|
||||
entryComponents: [MyComp],
|
||||
providers: [{provide: 'someToken', useValue: 'someValue'}],
|
||||
})
|
||||
class MyModule {
|
||||
}
|
||||
|
||||
const compFixture = TestBed.configureTestingModule({imports: [RootModule]})
|
||||
.createComponent(RootComp);
|
||||
const compiler = <Compiler>TestBed.get(Compiler);
|
||||
const myModule =
|
||||
compiler.compileModuleSync(MyModule).create(TestBed.get(NgModuleRef));
|
||||
const myCompFactory =
|
||||
myModule.componentFactoryResolver.resolveComponentFactory(MyComp);
|
||||
const compFixture = TestBed.configureTestingModule({imports: [RootModule]})
|
||||
.createComponent(RootComp);
|
||||
const compiler = <Compiler>TestBed.get(Compiler);
|
||||
const myModule =
|
||||
compiler.compileModuleSync(MyModule).create(TestBed.get(NgModuleRef));
|
||||
const myCompFactory =
|
||||
myModule.componentFactoryResolver.resolveComponentFactory(MyComp);
|
||||
|
||||
// Note: MyComp was declared as entryComponent in MyModule,
|
||||
// and we don't pass an explicit ModuleRef to the createComponent call.
|
||||
// -> expect the providers of MyModule!
|
||||
const compRef = compFixture.componentInstance.vc.createComponent(myCompFactory);
|
||||
expect(compRef.instance.someToken).toBe('someValue');
|
||||
});
|
||||
// Note: MyComp was declared as entryComponent in MyModule,
|
||||
// and we don't pass an explicit ModuleRef to the createComponent call.
|
||||
// -> expect the providers of MyModule!
|
||||
const compRef = compFixture.componentInstance.vc.createComponent(myCompFactory);
|
||||
expect(compRef.instance.someToken).toBe('someValue');
|
||||
});
|
||||
});
|
||||
|
||||
describe('.insert', () => {
|
||||
@ -1336,7 +1335,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(comp.injectable).toBeAnInstanceOf(InjectableService);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should support viewProviders', () => {
|
||||
fixmeIvy('unknown').it('should support viewProviders', () => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [MyComp, DirectiveProvidingInjectableInView, DirectiveConsumingInjectable],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
@ -1448,8 +1447,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(getDOM().querySelectorAll(fixture.nativeElement, 'script').length).toEqual(0);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-662: Components without selector are not supported') &&
|
||||
it('should throw when using directives without selector', () => {
|
||||
fixmeIvy('FW-662: Components without selector are not supported')
|
||||
.it('should throw when using directives without selector', () => {
|
||||
@Directive({})
|
||||
class SomeDirective {
|
||||
}
|
||||
@ -1496,8 +1495,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
describe('error handling', () => {
|
||||
fixmeIvy('FW-682: TestBed: tests assert that compilation produces specific error') &&
|
||||
it('should report a meaningful error when a directive is missing annotation', () => {
|
||||
fixmeIvy('FW-682: TestBed: tests assert that compilation produces specific error')
|
||||
.it('should report a meaningful error when a directive is missing annotation', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, SomeDirectiveMissingAnnotation]});
|
||||
|
||||
@ -1506,20 +1505,21 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
`Unexpected value '${stringify(SomeDirectiveMissingAnnotation)}' declared by the module 'DynamicTestModule'. Please add a @Pipe/@Directive/@Component annotation.`);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: TestBed: tests assert that compilation produces specific error') &&
|
||||
it('should report a meaningful error when a component is missing view annotation', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, ComponentWithoutView]});
|
||||
try {
|
||||
TestBed.createComponent(ComponentWithoutView);
|
||||
expect(true).toBe(false);
|
||||
} catch (e) {
|
||||
expect(e.message).toContain(
|
||||
`No template specified for component ${stringify(ComponentWithoutView)}`);
|
||||
}
|
||||
});
|
||||
fixmeIvy('FW-682: TestBed: tests assert that compilation produces specific error')
|
||||
.it('should report a meaningful error when a component is missing view annotation',
|
||||
() => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, ComponentWithoutView]});
|
||||
try {
|
||||
TestBed.createComponent(ComponentWithoutView);
|
||||
expect(true).toBe(false);
|
||||
} catch (e) {
|
||||
expect(e.message).toContain(
|
||||
`No template specified for component ${stringify(ComponentWithoutView)}`);
|
||||
}
|
||||
});
|
||||
|
||||
fixmeIvy('FW-722: getDebugContext needs to be replaced / re-implemented') &&
|
||||
it('should provide an error context when an error happens in DI', () => {
|
||||
fixmeIvy('FW-722: getDebugContext needs to be replaced / re-implemented')
|
||||
.it('should provide an error context when an error happens in DI', () => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [MyComp, DirectiveThrowingAnError],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
@ -1537,8 +1537,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
}
|
||||
});
|
||||
|
||||
fixmeIvy('FW-722: getDebugContext needs to be replaced / re-implemented') &&
|
||||
it('should provide an error context when an error happens in change detection', () => {
|
||||
fixmeIvy('FW-722: getDebugContext needs to be replaced / re-implemented')
|
||||
.it('should provide an error context when an error happens in change detection', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, DirectiveThrowingAnError]});
|
||||
const template = `<input [value]="one.two.three" #local>`;
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
@ -1556,50 +1556,50 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
}
|
||||
});
|
||||
|
||||
fixmeIvy('FW-722: getDebugContext needs to be replaced / re-implemented') &&
|
||||
it('should provide an error context when an error happens in change detection (text node)',
|
||||
() => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp]});
|
||||
const template = `<div>{{one.two.three}}</div>`;
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
try {
|
||||
fixture.detectChanges();
|
||||
throw 'Should throw';
|
||||
} catch (e) {
|
||||
const c = getDebugContext(e);
|
||||
expect(c.renderNode).toBeTruthy();
|
||||
}
|
||||
});
|
||||
fixmeIvy('FW-722: getDebugContext needs to be replaced / re-implemented')
|
||||
.it('should provide an error context when an error happens in change detection (text node)',
|
||||
() => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp]});
|
||||
const template = `<div>{{one.two.three}}</div>`;
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
try {
|
||||
fixture.detectChanges();
|
||||
throw 'Should throw';
|
||||
} catch (e) {
|
||||
const c = getDebugContext(e);
|
||||
expect(c.renderNode).toBeTruthy();
|
||||
}
|
||||
});
|
||||
|
||||
if (getDOM().supportsDOMEvents()) { // this is required to use fakeAsync
|
||||
fixmeIvy('FW-722: getDebugContext needs to be replaced / re-implemented') &&
|
||||
it('should provide an error context when an error happens in an event handler',
|
||||
fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
});
|
||||
const template = `<span emitter listener (event)="throwError()" #local></span>`;
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
tick();
|
||||
fixmeIvy('FW-722: getDebugContext needs to be replaced / re-implemented')
|
||||
.it('should provide an error context when an error happens in an event handler',
|
||||
fakeAsync(() => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent],
|
||||
schemas: [NO_ERRORS_SCHEMA],
|
||||
});
|
||||
const template = `<span emitter listener (event)="throwError()" #local></span>`;
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
tick();
|
||||
|
||||
const tc = fixture.debugElement.children[0];
|
||||
const tc = fixture.debugElement.children[0];
|
||||
|
||||
const errorHandler = tc.injector.get(ErrorHandler);
|
||||
let err: any;
|
||||
spyOn(errorHandler, 'handleError').and.callFake((e: any) => err = e);
|
||||
tc.injector.get(DirectiveEmittingEvent).fireEvent('boom');
|
||||
const errorHandler = tc.injector.get(ErrorHandler);
|
||||
let err: any;
|
||||
spyOn(errorHandler, 'handleError').and.callFake((e: any) => err = e);
|
||||
tc.injector.get(DirectiveEmittingEvent).fireEvent('boom');
|
||||
|
||||
expect(err).toBeTruthy();
|
||||
const c = getDebugContext(err);
|
||||
expect(getDOM().nodeName(c.renderNode).toUpperCase()).toEqual('SPAN');
|
||||
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
|
||||
expect((<Injector>c.injector).get).toBeTruthy();
|
||||
expect(c.context).toBe(fixture.componentInstance);
|
||||
expect(c.references['local']).toBeDefined();
|
||||
}));
|
||||
expect(err).toBeTruthy();
|
||||
const c = getDebugContext(err);
|
||||
expect(getDOM().nodeName(c.renderNode).toUpperCase()).toEqual('SPAN');
|
||||
expect(getDOM().nodeName(c.componentRenderElement).toUpperCase()).toEqual('DIV');
|
||||
expect((<Injector>c.injector).get).toBeTruthy();
|
||||
expect(c.context).toBe(fixture.componentInstance);
|
||||
expect(c.references['local']).toBeDefined();
|
||||
}));
|
||||
}
|
||||
});
|
||||
|
||||
@ -1636,8 +1636,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
describe('Property bindings', () => {
|
||||
fixmeIvy('FW-721: Bindings to unknown properties are not reported as errors') &&
|
||||
it('should throw on bindings to unknown properties', () => {
|
||||
fixmeIvy('FW-721: Bindings to unknown properties are not reported as errors')
|
||||
.it('should throw on bindings to unknown properties', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp]});
|
||||
const template = '<div unknown="{{ctxProp}}"></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
@ -1671,8 +1671,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(el.title).toBeFalsy();
|
||||
});
|
||||
|
||||
fixmeIvy('FW-711: elementProperty instruction should not be used in host bindings') &&
|
||||
it('should work when a directive uses hostProperty to update the DOM element', () => {
|
||||
fixmeIvy('FW-711: elementProperty instruction should not be used in host bindings')
|
||||
.it('should work when a directive uses hostProperty to update the DOM element', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MyComp, DirectiveWithTitleAndHostProperty]});
|
||||
const template = '<span [title]="ctxProp"></span>';
|
||||
@ -1688,8 +1688,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
describe('logging property updates', () => {
|
||||
fixmeIvy('FW-664: ng-reflect-* is not supported') &&
|
||||
it('should reflect property values as attributes', () => {
|
||||
fixmeIvy('FW-664: ng-reflect-* is not supported')
|
||||
.it('should reflect property values as attributes', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, MyDir]});
|
||||
const template = '<div>' +
|
||||
'<div my-dir [elprop]="ctxProp"></div>' +
|
||||
@ -1712,8 +1712,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(getDOM().getInnerHTML(fixture.nativeElement)).toContain('ng-reflect-test_="hello"');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-664: ng-reflect-* is not supported') &&
|
||||
it('should reflect property values on template comments', () => {
|
||||
fixmeIvy('FW-664: ng-reflect-* is not supported')
|
||||
.it('should reflect property values on template comments', () => {
|
||||
const fixture =
|
||||
TestBed.configureTestingModule({declarations: [MyComp]})
|
||||
.overrideComponent(
|
||||
@ -1729,8 +1729,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
// also affected by FW-587: Inputs with aliases in component decorators don't work
|
||||
fixmeIvy('FW-664: ng-reflect-* is not supported') &&
|
||||
it('should indicate when toString() throws', () => {
|
||||
fixmeIvy('FW-664: ng-reflect-* is not supported')
|
||||
.it('should indicate when toString() throws', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyComp, MyDir]});
|
||||
const template = '<div my-dir [elprop]="toStringThrow"></div>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
|
@ -138,8 +138,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
|
||||
afterEach(() => { resetTestEnvironmentWithSummaries(); });
|
||||
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
|
||||
it('should use directive metadata from summaries', () => {
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc')
|
||||
.it('should use directive metadata from summaries', () => {
|
||||
resetTestEnvironmentWithSummaries(summaries);
|
||||
|
||||
@Component({template: '<div someDir></div>'})
|
||||
@ -153,8 +153,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expectInstanceCreated(SomeDirective);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
|
||||
it('should use pipe metadata from summaries', () => {
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc')
|
||||
.it('should use pipe metadata from summaries', () => {
|
||||
resetTestEnvironmentWithSummaries(summaries);
|
||||
|
||||
@Component({template: '{{1 | somePipe}}'})
|
||||
@ -166,8 +166,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expectInstanceCreated(SomePipe);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
|
||||
it('should use Service metadata from summaries', () => {
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc')
|
||||
.it('should use Service metadata from summaries', () => {
|
||||
resetTestEnvironmentWithSummaries(summaries);
|
||||
|
||||
TestBed.configureTestingModule({
|
||||
@ -177,8 +177,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expectInstanceCreated(SomeService);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
|
||||
it('should use NgModule metadata from summaries', () => {
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc')
|
||||
.it('should use NgModule metadata from summaries', () => {
|
||||
resetTestEnvironmentWithSummaries(summaries);
|
||||
|
||||
TestBed
|
||||
@ -192,8 +192,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expectInstanceCreated(SomeService);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
|
||||
it('should allow to create private components from imported NgModule summaries', () => {
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc')
|
||||
.it('should allow to create private components from imported NgModule summaries', () => {
|
||||
resetTestEnvironmentWithSummaries(summaries);
|
||||
|
||||
TestBed.configureTestingModule({providers: [SomeDep], imports: [SomeModule]})
|
||||
@ -201,8 +201,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expectInstanceCreated(SomePrivateComponent);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
|
||||
it('should throw when trying to mock a type with a summary', () => {
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc')
|
||||
.it('should throw when trying to mock a type with a summary', () => {
|
||||
resetTestEnvironmentWithSummaries(summaries);
|
||||
|
||||
TestBed.resetTestingModule();
|
||||
@ -221,35 +221,35 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
.toThrowError('SomeModule was AOT compiled, so its metadata cannot be changed.');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
|
||||
it('should return stack trace and component data on resetTestingModule when error is thrown',
|
||||
() => {
|
||||
resetTestEnvironmentWithSummaries();
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc')
|
||||
.it('should return stack trace and component data on resetTestingModule when error is thrown',
|
||||
() => {
|
||||
resetTestEnvironmentWithSummaries();
|
||||
|
||||
const fixture =
|
||||
TestBed.configureTestingModule({declarations: [TestCompErrorOnDestroy]})
|
||||
.createComponent<TestCompErrorOnDestroy>(TestCompErrorOnDestroy);
|
||||
const fixture =
|
||||
TestBed.configureTestingModule({declarations: [TestCompErrorOnDestroy]})
|
||||
.createComponent<TestCompErrorOnDestroy>(TestCompErrorOnDestroy);
|
||||
|
||||
const expectedError = 'Error from ngOnDestroy';
|
||||
const expectedError = 'Error from ngOnDestroy';
|
||||
|
||||
const component: TestCompErrorOnDestroy = fixture.componentInstance;
|
||||
const component: TestCompErrorOnDestroy = fixture.componentInstance;
|
||||
|
||||
spyOn(console, 'error');
|
||||
spyOn(component, 'ngOnDestroy').and.throwError(expectedError);
|
||||
spyOn(console, 'error');
|
||||
spyOn(component, 'ngOnDestroy').and.throwError(expectedError);
|
||||
|
||||
const expectedObject = {
|
||||
stacktrace: new Error(expectedError),
|
||||
component,
|
||||
};
|
||||
const expectedObject = {
|
||||
stacktrace: new Error(expectedError),
|
||||
component,
|
||||
};
|
||||
|
||||
TestBed.resetTestingModule();
|
||||
TestBed.resetTestingModule();
|
||||
|
||||
expect(console.error)
|
||||
.toHaveBeenCalledWith('Error during cleanup of component', expectedObject);
|
||||
});
|
||||
expect(console.error)
|
||||
.toHaveBeenCalledWith('Error during cleanup of component', expectedObject);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
|
||||
it('should allow to add summaries via configureTestingModule', () => {
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc')
|
||||
.it('should allow to add summaries via configureTestingModule', () => {
|
||||
resetTestEnvironmentWithSummaries();
|
||||
|
||||
@Component({template: '<div someDir></div>'})
|
||||
@ -266,8 +266,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expectInstanceCreated(SomeDirective);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
|
||||
it('should allow to override a provider', () => {
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc')
|
||||
.it('should allow to override a provider', () => {
|
||||
resetTestEnvironmentWithSummaries(summaries);
|
||||
|
||||
const overwrittenValue = {};
|
||||
@ -280,8 +280,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(fixture.componentInstance.dep).toBe(overwrittenValue);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc') &&
|
||||
it('should allow to override a template', () => {
|
||||
fixmeIvy('FW-514: ngSummary shims not generated by ngtsc')
|
||||
.it('should allow to override a template', () => {
|
||||
resetTestEnvironmentWithSummaries(summaries);
|
||||
|
||||
TestBed.overrideTemplateUsingTestingModule(SomePublicComponent, 'overwritten');
|
||||
|
@ -52,8 +52,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(el).toHaveText('foo');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>') &&
|
||||
it('should be rendered as comment with children as siblings', () => {
|
||||
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>')
|
||||
.it('should be rendered as comment with children as siblings', () => {
|
||||
const template = '<ng-container><p></p></ng-container>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
@ -67,8 +67,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(getDOM().tagName(children[1]).toUpperCase()).toEqual('P');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>') &&
|
||||
it('should support nesting', () => {
|
||||
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>')
|
||||
.it('should support nesting', () => {
|
||||
const template =
|
||||
'<ng-container>1</ng-container><ng-container><ng-container>2</ng-container></ng-container>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
@ -86,8 +86,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(children[4]).toHaveText('2');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>') &&
|
||||
it('should group inner nodes', () => {
|
||||
fixmeIvy('FW-678: ivy generates different DOM structure for <ng-container>')
|
||||
.it('should group inner nodes', () => {
|
||||
const template = '<ng-container *ngIf="ctxBoolProp"><p></p><b></b></ng-container>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
@ -136,8 +136,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(dir.text).toEqual('container');
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should contain all direct child directives in a <ng-container> (content dom)', () => {
|
||||
fixmeIvy('unknown').it(
|
||||
'should contain all direct child directives in a <ng-container> (content dom)', () => {
|
||||
const template =
|
||||
'<needs-content-children #q><ng-container><div text="foo"></div></ng-container></needs-content-children>';
|
||||
TestBed.overrideComponent(MyComp, {set: {template}});
|
||||
|
@ -143,8 +143,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
}
|
||||
|
||||
describe('errors', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should error when exporting a directive that was neither declared nor imported', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should error when exporting a directive that was neither declared nor imported', () => {
|
||||
@NgModule({exports: [SomeDirective]})
|
||||
class SomeModule {
|
||||
}
|
||||
@ -154,8 +154,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
`Can't export directive ${stringify(SomeDirective)} from ${stringify(SomeModule)} as it was neither declared nor imported!`);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should error when exporting a pipe that was neither declared nor imported', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should error when exporting a pipe that was neither declared nor imported', () => {
|
||||
@NgModule({exports: [SomePipe]})
|
||||
class SomeModule {
|
||||
}
|
||||
@ -165,8 +165,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
`Can't export pipe ${stringify(SomePipe)} from ${stringify(SomeModule)} as it was neither declared nor imported!`);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should error if a directive is declared in more than 1 module', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should error if a directive is declared in more than 1 module', () => {
|
||||
@NgModule({declarations: [SomeDirective]})
|
||||
class Module1 {
|
||||
}
|
||||
@ -184,26 +184,26 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
`You can also create a new NgModule that exports and includes ${stringify(SomeDirective)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should error if a directive is declared in more than 1 module also if the module declaring it is imported',
|
||||
() => {
|
||||
@NgModule({declarations: [SomeDirective], exports: [SomeDirective]})
|
||||
class Module1 {
|
||||
}
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should error if a directive is declared in more than 1 module also if the module declaring it is imported',
|
||||
() => {
|
||||
@NgModule({declarations: [SomeDirective], exports: [SomeDirective]})
|
||||
class Module1 {
|
||||
}
|
||||
|
||||
@NgModule({declarations: [SomeDirective], imports: [Module1]})
|
||||
class Module2 {
|
||||
}
|
||||
@NgModule({declarations: [SomeDirective], imports: [Module1]})
|
||||
class Module2 {
|
||||
}
|
||||
|
||||
expect(() => createModule(Module2))
|
||||
.toThrowError(
|
||||
`Type ${stringify(SomeDirective)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
|
||||
`Please consider moving ${stringify(SomeDirective)} to a higher module that imports ${stringify(Module1)} and ${stringify(Module2)}. ` +
|
||||
`You can also create a new NgModule that exports and includes ${stringify(SomeDirective)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`);
|
||||
});
|
||||
expect(() => createModule(Module2))
|
||||
.toThrowError(
|
||||
`Type ${stringify(SomeDirective)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
|
||||
`Please consider moving ${stringify(SomeDirective)} to a higher module that imports ${stringify(Module1)} and ${stringify(Module2)}. ` +
|
||||
`You can also create a new NgModule that exports and includes ${stringify(SomeDirective)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should error if a pipe is declared in more than 1 module', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should error if a pipe is declared in more than 1 module', () => {
|
||||
@NgModule({declarations: [SomePipe]})
|
||||
class Module1 {
|
||||
}
|
||||
@ -221,29 +221,29 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
`You can also create a new NgModule that exports and includes ${stringify(SomePipe)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should error if a pipe is declared in more than 1 module also if the module declaring it is imported',
|
||||
() => {
|
||||
@NgModule({declarations: [SomePipe], exports: [SomePipe]})
|
||||
class Module1 {
|
||||
}
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should error if a pipe is declared in more than 1 module also if the module declaring it is imported',
|
||||
() => {
|
||||
@NgModule({declarations: [SomePipe], exports: [SomePipe]})
|
||||
class Module1 {
|
||||
}
|
||||
|
||||
@NgModule({declarations: [SomePipe], imports: [Module1]})
|
||||
class Module2 {
|
||||
}
|
||||
@NgModule({declarations: [SomePipe], imports: [Module1]})
|
||||
class Module2 {
|
||||
}
|
||||
|
||||
expect(() => createModule(Module2))
|
||||
.toThrowError(
|
||||
`Type ${stringify(SomePipe)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
|
||||
`Please consider moving ${stringify(SomePipe)} to a higher module that imports ${stringify(Module1)} and ${stringify(Module2)}. ` +
|
||||
`You can also create a new NgModule that exports and includes ${stringify(SomePipe)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`);
|
||||
});
|
||||
expect(() => createModule(Module2))
|
||||
.toThrowError(
|
||||
`Type ${stringify(SomePipe)} is part of the declarations of 2 modules: ${stringify(Module1)} and ${stringify(Module2)}! ` +
|
||||
`Please consider moving ${stringify(SomePipe)} to a higher module that imports ${stringify(Module1)} and ${stringify(Module2)}. ` +
|
||||
`You can also create a new NgModule that exports and includes ${stringify(SomePipe)} then import that NgModule in ${stringify(Module1)} and ${stringify(Module2)}.`);
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
describe('schemas', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should error on unknown bound properties on custom elements by default', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should error on unknown bound properties on custom elements by default', () => {
|
||||
@Component({template: '<some-element [someUnknownProp]="true"></some-element>'})
|
||||
class ComponentUsingInvalidProperty {
|
||||
}
|
||||
@ -281,16 +281,16 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
|
||||
afterEach(() => clearModulesForTest());
|
||||
|
||||
fixmeIvy('FW-740: missing global registry of NgModules by id') &&
|
||||
it('should register loaded modules', () => {
|
||||
fixmeIvy('FW-740: missing global registry of NgModules by id')
|
||||
.it('should register loaded modules', () => {
|
||||
createModule(SomeModule);
|
||||
const factory = getModuleFactory(token);
|
||||
expect(factory).toBeTruthy();
|
||||
expect(factory.moduleType).toBe(SomeModule);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should throw when registering a duplicate module', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should throw when registering a duplicate module', () => {
|
||||
createModule(SomeModule);
|
||||
expect(() => createModule(SomeOtherModule)).toThrowError(/Duplicate module registered/);
|
||||
});
|
||||
@ -311,37 +311,37 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
.toBe(SomeComp);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should throw if we cannot find a module associated with a module-level entryComponent',
|
||||
() => {
|
||||
@Component({template: ''})
|
||||
class SomeCompWithEntryComponents {
|
||||
}
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should throw if we cannot find a module associated with a module-level entryComponent',
|
||||
() => {
|
||||
@Component({template: ''})
|
||||
class SomeCompWithEntryComponents {
|
||||
}
|
||||
|
||||
@NgModule({declarations: [], entryComponents: [SomeCompWithEntryComponents]})
|
||||
class SomeModule {
|
||||
}
|
||||
@NgModule({declarations: [], entryComponents: [SomeCompWithEntryComponents]})
|
||||
class SomeModule {
|
||||
}
|
||||
|
||||
expect(() => createModule(SomeModule))
|
||||
.toThrowError(
|
||||
'Component SomeCompWithEntryComponents is not part of any NgModule or the module has not been imported into your module.');
|
||||
});
|
||||
expect(() => createModule(SomeModule))
|
||||
.toThrowError(
|
||||
'Component SomeCompWithEntryComponents is not part of any NgModule or the module has not been imported into your module.');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should throw if we cannot find a module associated with a component-level entryComponent',
|
||||
() => {
|
||||
@Component({template: '', entryComponents: [SomeComp]})
|
||||
class SomeCompWithEntryComponents {
|
||||
}
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should throw if we cannot find a module associated with a component-level entryComponent',
|
||||
() => {
|
||||
@Component({template: '', entryComponents: [SomeComp]})
|
||||
class SomeCompWithEntryComponents {
|
||||
}
|
||||
|
||||
@NgModule({declarations: [SomeCompWithEntryComponents]})
|
||||
class SomeModule {
|
||||
}
|
||||
@NgModule({declarations: [SomeCompWithEntryComponents]})
|
||||
class SomeModule {
|
||||
}
|
||||
|
||||
expect(() => createModule(SomeModule))
|
||||
.toThrowError(
|
||||
'Component SomeComp is not part of any NgModule or the module has not been imported into your module.');
|
||||
});
|
||||
expect(() => createModule(SomeModule))
|
||||
.toThrowError(
|
||||
'Component SomeComp is not part of any NgModule or the module has not been imported into your module.');
|
||||
});
|
||||
|
||||
it('should create ComponentFactories via ANALYZE_FOR_ENTRY_COMPONENTS', () => {
|
||||
@NgModule({
|
||||
@ -426,8 +426,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
describe('directives and pipes', () => {
|
||||
fixmeIvy('FW-681: not possible to retrieve host property bindings from TView') &&
|
||||
describe('declarations', () => {
|
||||
fixmeIvy('FW-681: not possible to retrieve host property bindings from TView')
|
||||
.describe('declarations', () => {
|
||||
it('should be supported in root modules', () => {
|
||||
@NgModule({
|
||||
declarations: [CompUsingModuleDirectiveAndPipe, SomeDirective, SomePipe],
|
||||
@ -489,8 +489,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
|
||||
describe('import/export', () => {
|
||||
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account') &&
|
||||
it('should support exported directives and pipes', () => {
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account')
|
||||
.it('should support exported directives and pipes', () => {
|
||||
@NgModule(
|
||||
{declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
|
||||
class SomeImportedModule {
|
||||
@ -511,31 +511,31 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
.toBe('transformed someValue');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account') &&
|
||||
it('should support exported directives and pipes if the module is wrapped into an `ModuleWithProviders`',
|
||||
() => {
|
||||
@NgModule(
|
||||
{declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
|
||||
class SomeImportedModule {
|
||||
}
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account')
|
||||
.it('should support exported directives and pipes if the module is wrapped into an `ModuleWithProviders`',
|
||||
() => {
|
||||
@NgModule(
|
||||
{declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
|
||||
class SomeImportedModule {
|
||||
}
|
||||
|
||||
@NgModule({
|
||||
declarations: [CompUsingModuleDirectiveAndPipe],
|
||||
imports: [{ngModule: SomeImportedModule}],
|
||||
entryComponents: [CompUsingModuleDirectiveAndPipe]
|
||||
})
|
||||
class SomeModule {
|
||||
}
|
||||
@NgModule({
|
||||
declarations: [CompUsingModuleDirectiveAndPipe],
|
||||
imports: [{ngModule: SomeImportedModule}],
|
||||
entryComponents: [CompUsingModuleDirectiveAndPipe]
|
||||
})
|
||||
class SomeModule {
|
||||
}
|
||||
|
||||
|
||||
const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
|
||||
compFixture.detectChanges();
|
||||
expect(compFixture.debugElement.children[0].properties['title'])
|
||||
.toBe('transformed someValue');
|
||||
});
|
||||
const compFixture = createComp(CompUsingModuleDirectiveAndPipe, SomeModule);
|
||||
compFixture.detectChanges();
|
||||
expect(compFixture.debugElement.children[0].properties['title'])
|
||||
.toBe('transformed someValue');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account') &&
|
||||
it('should support reexported modules', () => {
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account')
|
||||
.it('should support reexported modules', () => {
|
||||
@NgModule(
|
||||
{declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
|
||||
class SomeReexportedModule {
|
||||
@ -559,8 +559,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
.toBe('transformed someValue');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account') &&
|
||||
it('should support exporting individual directives of an imported module', () => {
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account')
|
||||
.it('should support exporting individual directives of an imported module', () => {
|
||||
@NgModule(
|
||||
{declarations: [SomeDirective, SomePipe], exports: [SomeDirective, SomePipe]})
|
||||
class SomeReexportedModule {
|
||||
@ -584,8 +584,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
.toBe('transformed someValue');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should not use non exported pipes of an imported module', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should not use non exported pipes of an imported module', () => {
|
||||
@NgModule({
|
||||
declarations: [SomePipe],
|
||||
})
|
||||
@ -604,8 +604,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
.toThrowError(/The pipe 'somePipe' could not be found/);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should not use non exported directives of an imported module', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should not use non exported directives of an imported module', () => {
|
||||
@NgModule({
|
||||
declarations: [SomeDirective],
|
||||
})
|
||||
@ -667,14 +667,14 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(car.engine).toBeAnInstanceOf(TurboEngine);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should throw when no type and not @Inject (class case)', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should throw when no type and not @Inject (class case)', () => {
|
||||
expect(() => createInjector([NoAnnotations]))
|
||||
.toThrowError('Can\'t resolve all parameters for NoAnnotations: (?).');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should throw when no type and not @Inject (factory case)', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should throw when no type and not @Inject (factory case)', () => {
|
||||
expect(() => createInjector([{provide: 'someToken', useFactory: factoryFn}]))
|
||||
.toThrowError('Can\'t resolve all parameters for factoryFn: (?).');
|
||||
});
|
||||
@ -745,8 +745,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(cars[0]).toBe(injector.get(SportsCar));
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should throw when the aliased provider does not exist', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should throw when the aliased provider does not exist', () => {
|
||||
const injector = createInjector([{provide: 'car', useExisting: SportsCar}]);
|
||||
const e = `NullInjectorError: No provider for ${stringify(SportsCar)}!`;
|
||||
expect(() => injector.get('car')).toThrowError(e);
|
||||
@ -796,14 +796,13 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(injector.get('token')).toEqual('value');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should throw when given invalid providers', () => {
|
||||
expect(() => createInjector(<any>['blah']))
|
||||
.toThrowError(
|
||||
`Invalid provider for the NgModule 'SomeModule' - only instances of Provider and Type are allowed, got: [?blah?]`);
|
||||
});
|
||||
fixmeIvy('FW-682: Compiler error handling').it('should throw when given invalid providers', () => {
|
||||
expect(() => createInjector(<any>['blah']))
|
||||
.toThrowError(
|
||||
`Invalid provider for the NgModule 'SomeModule' - only instances of Provider and Type are allowed, got: [?blah?]`);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') && it('should throw when given blank providers', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling').it('should throw when given blank providers', () => {
|
||||
expect(() => createInjector(<any>[null, {provide: 'token', useValue: 'value'}]))
|
||||
.toThrowError(
|
||||
`Invalid provider for the NgModule 'SomeModule' - only instances of Provider and Type are allowed, got: [?null?, ...]`);
|
||||
@ -949,8 +948,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
.toThrowError('NullInjectorError: No provider for NonExisting!');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should throw when trying to instantiate a cyclic dependency', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should throw when trying to instantiate a cyclic dependency', () => {
|
||||
expect(() => createInjector([Car, {provide: Engine, useClass: CyclicEngine}]))
|
||||
.toThrowError(/Cannot instantiate cyclic dependency! Car/g);
|
||||
});
|
||||
@ -1053,8 +1052,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(created).toBe(false);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-739: TestBed: destroy on NgModuleRef is not being called') &&
|
||||
it('should support ngOnDestroy on any provider', () => {
|
||||
fixmeIvy('FW-739: TestBed: destroy on NgModuleRef is not being called')
|
||||
.it('should support ngOnDestroy on any provider', () => {
|
||||
let destroyed = false;
|
||||
|
||||
class SomeInjectable {
|
||||
@ -1073,8 +1072,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(destroyed).toBe(true);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-739: TestBed: destroy on NgModuleRef is not being called') &&
|
||||
it('should support ngOnDestroy for lazy providers', () => {
|
||||
fixmeIvy('FW-739: TestBed: destroy on NgModuleRef is not being called')
|
||||
.it('should support ngOnDestroy for lazy providers', () => {
|
||||
let created = false;
|
||||
let destroyed = false;
|
||||
|
||||
@ -1318,8 +1317,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(injector.get('token1')).toBe('imported2');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682: Compiler error handling') &&
|
||||
it('should throw when given invalid providers in an imported ModuleWithProviders', () => {
|
||||
fixmeIvy('FW-682: Compiler error handling')
|
||||
.it('should throw when given invalid providers in an imported ModuleWithProviders', () => {
|
||||
@NgModule()
|
||||
class ImportedModule1 {
|
||||
}
|
||||
@ -1335,8 +1334,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
describe('tree shakable providers', () => {
|
||||
fixmeIvy('FW-794: NgModuleDefinition not exposed on NgModuleData') &&
|
||||
it('definition should not persist across NgModuleRef instances', () => {
|
||||
fixmeIvy('FW-794: NgModuleDefinition not exposed on NgModuleData')
|
||||
.it('definition should not persist across NgModuleRef instances', () => {
|
||||
@NgModule()
|
||||
class SomeModule {
|
||||
}
|
||||
|
@ -82,8 +82,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(main.nativeElement).toHaveText('');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-789: select attribute on <ng-content> should not be case-sensitive') &&
|
||||
it('should support multiple content tags', () => {
|
||||
fixmeIvy('FW-789: select attribute on <ng-content> should not be case-sensitive')
|
||||
.it('should support multiple content tags', () => {
|
||||
TestBed.configureTestingModule({declarations: [MultipleContentTagsComponent]});
|
||||
TestBed.overrideComponent(MainComp, {
|
||||
set: {
|
||||
@ -114,8 +114,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(main.nativeElement).toHaveText('(, BAC)');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
|
||||
it('should redistribute direct child viewcontainers when the light dom changes', () => {
|
||||
fixmeIvy('FW-665: Unable to find the given context data for the given target')
|
||||
.it('should redistribute direct child viewcontainers when the light dom changes', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [MultipleContentTagsComponent, ManualViewportDirective]});
|
||||
TestBed.overrideComponent(MainComp, {
|
||||
@ -158,8 +158,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(main.nativeElement).toHaveText('OUTER(SIMPLE(AB))');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
|
||||
it('should support nesting with content being direct child of a nested component', () => {
|
||||
fixmeIvy('FW-665: Unable to find the given context data for the given target')
|
||||
.it('should support nesting with content being direct child of a nested component', () => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations:
|
||||
[InnerComponent, InnerInnerComponent, OuterComponent, ManualViewportDirective]
|
||||
@ -186,8 +186,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-745: Compiler isn\'t generating projectionDefs for <ng-content> tags inside <ng-templates>') &&
|
||||
it('should redistribute when the shadow dom changes', () => {
|
||||
'FW-745: Compiler isn\'t generating projectionDefs for <ng-content> tags inside <ng-templates>')
|
||||
.it('should redistribute when the shadow dom changes', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [ConditionalContentComponent, ManualViewportDirective]});
|
||||
TestBed.overrideComponent(MainComp, {
|
||||
@ -295,8 +295,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(main.nativeElement).toHaveText('SIMPLE()START(A)END');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
|
||||
it('should support moving ng-content around', () => {
|
||||
fixmeIvy('FW-665: Unable to find the given context data for the given target')
|
||||
.it('should support moving ng-content around', () => {
|
||||
TestBed.configureTestingModule({
|
||||
declarations:
|
||||
[ConditionalContentComponent, ProjectDirective, ManualViewportDirective]
|
||||
@ -435,8 +435,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
});
|
||||
}
|
||||
|
||||
fixmeIvy('FW-665: Unable to find the given context data for the given target') &&
|
||||
it('should support nested conditionals that contain ng-contents', () => {
|
||||
fixmeIvy('FW-665: Unable to find the given context data for the given target')
|
||||
.it('should support nested conditionals that contain ng-contents', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [ConditionalTextComponent, ManualViewportDirective]});
|
||||
TestBed.overrideComponent(
|
||||
@ -482,8 +482,8 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-745: Compiler isn\'t generating projectionDefs for <ng-content> tags inside <ng-templates>') &&
|
||||
it('should project filled view containers into a view container', () => {
|
||||
'FW-745: Compiler isn\'t generating projectionDefs for <ng-content> tags inside <ng-templates>')
|
||||
.it('should project filled view containers into a view container', () => {
|
||||
TestBed.configureTestingModule(
|
||||
{declarations: [ConditionalContentComponent, ManualViewportDirective]});
|
||||
TestBed.overrideComponent(MainComp, {
|
||||
|
@ -54,8 +54,8 @@ describe('Query API', () => {
|
||||
|
||||
describe('querying by directive type', () => {
|
||||
fixmeIvy(
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy') &&
|
||||
it('should contain all direct child directives in the light dom (constructor)', () => {
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy')
|
||||
.it('should contain all direct child directives in the light dom (constructor)', () => {
|
||||
const template = `
|
||||
<div text="1"></div>
|
||||
<needs-query text="2">
|
||||
@ -97,23 +97,23 @@ describe('Query API', () => {
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy') &&
|
||||
it('should contain the first content child when target is on <ng-template> with embedded view (issue #16568)',
|
||||
() => {
|
||||
const template =
|
||||
'<div directive-needs-content-child><ng-template text="foo" [ngIf]="true"><div text="bar"></div></ng-template></div>' +
|
||||
'<needs-content-child #q><ng-template text="foo" [ngIf]="true"><div text="bar"></div></ng-template></needs-content-child>';
|
||||
const view = createTestCmp(MyComp0, template);
|
||||
view.detectChanges();
|
||||
const q: NeedsContentChild = view.debugElement.children[1].references !['q'];
|
||||
expect(q.child.text).toEqual('foo');
|
||||
const directive: DirectiveNeedsContentChild =
|
||||
view.debugElement.children[0].injector.get(DirectiveNeedsContentChild);
|
||||
expect(directive.child.text).toEqual('foo');
|
||||
});
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy')
|
||||
.it('should contain the first content child when target is on <ng-template> with embedded view (issue #16568)',
|
||||
() => {
|
||||
const template =
|
||||
'<div directive-needs-content-child><ng-template text="foo" [ngIf]="true"><div text="bar"></div></ng-template></div>' +
|
||||
'<needs-content-child #q><ng-template text="foo" [ngIf]="true"><div text="bar"></div></ng-template></needs-content-child>';
|
||||
const view = createTestCmp(MyComp0, template);
|
||||
view.detectChanges();
|
||||
const q: NeedsContentChild = view.debugElement.children[1].references !['q'];
|
||||
expect(q.child.text).toEqual('foo');
|
||||
const directive: DirectiveNeedsContentChild =
|
||||
view.debugElement.children[0].injector.get(DirectiveNeedsContentChild);
|
||||
expect(directive.child.text).toEqual('foo');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-782 - View queries are executed twice in some cases') &&
|
||||
it('should contain the first view child', () => {
|
||||
fixmeIvy('FW-782 - View queries are executed twice in some cases')
|
||||
.it('should contain the first view child', () => {
|
||||
const template = '<needs-view-child #q></needs-view-child>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
|
||||
@ -128,8 +128,8 @@ describe('Query API', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-782 - View queries are executed twice in some cases') &&
|
||||
it('should set static view and content children already after the constructor call', () => {
|
||||
fixmeIvy('FW-782 - View queries are executed twice in some cases')
|
||||
.it('should set static view and content children already after the constructor call', () => {
|
||||
const template =
|
||||
'<needs-static-content-view-child #q><div text="contentFoo"></div></needs-static-content-view-child>';
|
||||
const view = createTestCmp(MyComp0, template);
|
||||
@ -142,8 +142,8 @@ describe('Query API', () => {
|
||||
expect(q.viewChild.text).toEqual('viewFoo');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-782 - View queries are executed twice in some cases') &&
|
||||
it('should contain the first view child across embedded views', () => {
|
||||
fixmeIvy('FW-782 - View queries are executed twice in some cases')
|
||||
.it('should contain the first view child across embedded views', () => {
|
||||
TestBed.overrideComponent(
|
||||
MyComp0, {set: {template: '<needs-view-child #q></needs-view-child>'}});
|
||||
TestBed.overrideComponent(NeedsViewChild, {
|
||||
@ -172,8 +172,8 @@ describe('Query API', () => {
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy') &&
|
||||
it('should contain all directives in the light dom when descendants flag is used', () => {
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy')
|
||||
.it('should contain all directives in the light dom when descendants flag is used', () => {
|
||||
const template = '<div text="1"></div>' +
|
||||
'<needs-query-desc text="2"><div text="3">' +
|
||||
'<div text="4"></div>' +
|
||||
@ -185,8 +185,8 @@ describe('Query API', () => {
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy') &&
|
||||
it('should contain all directives in the light dom', () => {
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy')
|
||||
.it('should contain all directives in the light dom', () => {
|
||||
const template = '<div text="1"></div>' +
|
||||
'<needs-query text="2"><div text="3"></div></needs-query>' +
|
||||
'<div text="4"></div>';
|
||||
@ -196,8 +196,8 @@ describe('Query API', () => {
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy') &&
|
||||
it('should reflect dynamically inserted directives', () => {
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy')
|
||||
.it('should reflect dynamically inserted directives', () => {
|
||||
const template = '<div text="1"></div>' +
|
||||
'<needs-query text="2"><div *ngIf="shouldShow" [text]="\'3\'"></div></needs-query>' +
|
||||
'<div text="4"></div>';
|
||||
@ -221,8 +221,8 @@ describe('Query API', () => {
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy') &&
|
||||
it('should reflect moved directives', () => {
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy')
|
||||
.it('should reflect moved directives', () => {
|
||||
const template = '<div text="1"></div>' +
|
||||
'<needs-query text="2"><div *ngFor="let i of list" [text]="i"></div></needs-query>' +
|
||||
'<div text="4"></div>';
|
||||
@ -234,8 +234,8 @@ describe('Query API', () => {
|
||||
expect(asNativeElements(view.debugElement.children)).toHaveText('2|3d|2d|');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-682 - TestBed: tests assert that compilation produces specific error') &&
|
||||
it('should throw with descriptive error when query selectors are not present', () => {
|
||||
fixmeIvy('FW-682 - TestBed: tests assert that compilation produces specific error')
|
||||
.it('should throw with descriptive error when query selectors are not present', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyCompBroken0, HasNullQueryCondition]});
|
||||
const template = '<has-null-query-condition></has-null-query-condition>';
|
||||
TestBed.overrideComponent(MyCompBroken0, {set: {template}});
|
||||
@ -268,8 +268,8 @@ describe('Query API', () => {
|
||||
|
||||
describe('read a different token', () => {
|
||||
modifiedInIvy(
|
||||
'Breaking change in Ivy: no longer allow multiple local refs with the same name, all local refs are now unique') &&
|
||||
it('should contain all content children', () => {
|
||||
'Breaking change in Ivy: no longer allow multiple local refs with the same name, all local refs are now unique')
|
||||
.it('should contain all content children', () => {
|
||||
const template =
|
||||
'<needs-content-children-read #q text="ca"><div #q text="cb"></div></needs-content-children-read>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
@ -477,17 +477,19 @@ describe('Query API', () => {
|
||||
|
||||
describe('querying in the view', () => {
|
||||
fixmeIvy(
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy') &&
|
||||
it('should contain all the elements in the view with that have the given directive', () => {
|
||||
const template = '<needs-view-query #q><div text="ignoreme"></div></needs-view-query>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q: NeedsViewQuery = view.debugElement.children[0].references !['q'];
|
||||
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '2', '3', '4']);
|
||||
});
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy')
|
||||
.it('should contain all the elements in the view with that have the given directive',
|
||||
() => {
|
||||
const template =
|
||||
'<needs-view-query #q><div text="ignoreme"></div></needs-view-query>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q: NeedsViewQuery = view.debugElement.children[0].references !['q'];
|
||||
expect(q.query.map((d: TextDirective) => d.text)).toEqual(['1', '2', '3', '4']);
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy') &&
|
||||
it('should not include directive present on the host element', () => {
|
||||
'FW-781 - Directives invocation sequence on root and nested elements is different in Ivy')
|
||||
.it('should not include directive present on the host element', () => {
|
||||
const template = '<needs-view-query #q text="self"></needs-view-query>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
const q: NeedsViewQuery = view.debugElement.children[0].references !['q'];
|
||||
@ -588,8 +590,8 @@ describe('Query API', () => {
|
||||
});
|
||||
|
||||
// Note: this test is just document our current behavior, which we do for performance reasons.
|
||||
fixmeIvy('FW-782 - View queries are executed twice in some cases') &&
|
||||
it('should not affected queries for projected templates if views are detached or moved', () => {
|
||||
fixmeIvy('FW-782 - View queries are executed twice in some cases')
|
||||
.it('should not affected queries for projected templates if views are detached or moved', () => {
|
||||
const template =
|
||||
'<manual-projecting #q><ng-template let-x="x"><div [text]="x"></div></ng-template></manual-projecting>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
@ -615,8 +617,8 @@ describe('Query API', () => {
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-763 - LView tree not properly constructed / destroyed for dynamically inserted components') &&
|
||||
it('should remove manually projected templates if their parent view is destroyed', () => {
|
||||
'FW-763 - LView tree not properly constructed / destroyed for dynamically inserted components')
|
||||
.it('should remove manually projected templates if their parent view is destroyed', () => {
|
||||
const template = `
|
||||
<manual-projecting #q><ng-template #tpl><div text="1"></div></ng-template></manual-projecting>
|
||||
<div *ngIf="shouldShow">
|
||||
@ -635,34 +637,34 @@ describe('Query API', () => {
|
||||
expect(q.query.length).toBe(0);
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should not throw if a content template is queried and created in the view during change detection',
|
||||
() => {
|
||||
@Component(
|
||||
{selector: 'auto-projecting', template: '<div *ngIf="true; then: content"></div>'})
|
||||
class AutoProjecting {
|
||||
// TODO(issue/24571):
|
||||
// remove '!'.
|
||||
@ContentChild(TemplateRef)
|
||||
content !: TemplateRef<any>;
|
||||
fixmeIvy('unknown').it(
|
||||
'should not throw if a content template is queried and created in the view during change detection',
|
||||
() => {
|
||||
@Component(
|
||||
{selector: 'auto-projecting', template: '<div *ngIf="true; then: content"></div>'})
|
||||
class AutoProjecting {
|
||||
// TODO(issue/24571):
|
||||
// remove '!'.
|
||||
@ContentChild(TemplateRef)
|
||||
content !: TemplateRef<any>;
|
||||
|
||||
// TODO(issue/24571):
|
||||
// remove '!'.
|
||||
@ContentChildren(TextDirective)
|
||||
query !: QueryList<TextDirective>;
|
||||
}
|
||||
// TODO(issue/24571):
|
||||
// remove '!'.
|
||||
@ContentChildren(TextDirective)
|
||||
query !: QueryList<TextDirective>;
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [AutoProjecting]});
|
||||
const template =
|
||||
'<auto-projecting #q><ng-template><div text="1"></div></ng-template></auto-projecting>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
TestBed.configureTestingModule({declarations: [AutoProjecting]});
|
||||
const template =
|
||||
'<auto-projecting #q><ng-template><div text="1"></div></ng-template></auto-projecting>';
|
||||
const view = createTestCmpAndDetectChanges(MyComp0, template);
|
||||
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
// This should be 1, but due to
|
||||
// https://github.com/angular/angular/issues/15117
|
||||
// this is 0.
|
||||
expect(q.query.length).toBe(0);
|
||||
});
|
||||
const q = view.debugElement.children[0].references !['q'];
|
||||
// This should be 1, but due to
|
||||
// https://github.com/angular/angular/issues/15117
|
||||
// this is 0.
|
||||
expect(q.query.length).toBe(0);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
|
@ -32,7 +32,7 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
describe('platform pipes', () => {
|
||||
beforeEach(() => { TestBed.configureCompiler({...config}); });
|
||||
|
||||
fixmeIvy('unknown') && it('should overwrite them by custom pipes', () => {
|
||||
fixmeIvy('unknown').it('should overwrite them by custom pipes', () => {
|
||||
TestBed.configureTestingModule({declarations: [CustomPipe]});
|
||||
const template = '{{true | somePipe}}';
|
||||
TestBed.overrideComponent(MyComp1, {set: {template}});
|
||||
@ -74,46 +74,46 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(CountingPipe.calls).toBe(1);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account') &&
|
||||
it('should only update the bound property when using asyncPipe - #15205',
|
||||
fakeAsync(() => {
|
||||
@Component({template: '<div myDir [a]="p | async" [b]="2"></div>'})
|
||||
class MyComp {
|
||||
p = Promise.resolve(1);
|
||||
}
|
||||
fixmeIvy('FW-756: Pipes and directives from imported modules are not taken into account')
|
||||
.it('should only update the bound property when using asyncPipe - #15205',
|
||||
fakeAsync(() => {
|
||||
@Component({template: '<div myDir [a]="p | async" [b]="2"></div>'})
|
||||
class MyComp {
|
||||
p = Promise.resolve(1);
|
||||
}
|
||||
|
||||
@Directive({selector: '[myDir]'})
|
||||
class MyDir {
|
||||
setterCalls: {[key: string]: any} = {};
|
||||
// TODO(issue/24571): remove '!'.
|
||||
changes !: SimpleChanges;
|
||||
@Directive({selector: '[myDir]'})
|
||||
class MyDir {
|
||||
setterCalls: {[key: string]: any} = {};
|
||||
// TODO(issue/24571): remove '!'.
|
||||
changes !: SimpleChanges;
|
||||
|
||||
@Input()
|
||||
set a(v: number) { this.setterCalls['a'] = v; }
|
||||
@Input()
|
||||
set b(v: number) { this.setterCalls['b'] = v; }
|
||||
@Input()
|
||||
set a(v: number) { this.setterCalls['a'] = v; }
|
||||
@Input()
|
||||
set b(v: number) { this.setterCalls['b'] = v; }
|
||||
|
||||
ngOnChanges(changes: SimpleChanges) { this.changes = changes; }
|
||||
}
|
||||
ngOnChanges(changes: SimpleChanges) { this.changes = changes; }
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
const dir =
|
||||
fixture.debugElement.query(By.directive(MyDir)).injector.get(MyDir) as MyDir;
|
||||
TestBed.configureTestingModule({declarations: [MyDir, MyComp]});
|
||||
const fixture = TestBed.createComponent(MyComp);
|
||||
const dir =
|
||||
fixture.debugElement.query(By.directive(MyDir)).injector.get(MyDir) as MyDir;
|
||||
|
||||
fixture.detectChanges();
|
||||
expect(dir.setterCalls).toEqual({'a': null, 'b': 2});
|
||||
expect(Object.keys(dir.changes)).toEqual(['a', 'b']);
|
||||
fixture.detectChanges();
|
||||
expect(dir.setterCalls).toEqual({'a': null, 'b': 2});
|
||||
expect(Object.keys(dir.changes)).toEqual(['a', 'b']);
|
||||
|
||||
dir.setterCalls = {};
|
||||
dir.changes = {};
|
||||
dir.setterCalls = {};
|
||||
dir.changes = {};
|
||||
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
tick();
|
||||
fixture.detectChanges();
|
||||
|
||||
expect(dir.setterCalls).toEqual({'a': 1});
|
||||
expect(Object.keys(dir.changes)).toEqual(['a']);
|
||||
}));
|
||||
expect(dir.setterCalls).toEqual({'a': 1});
|
||||
expect(Object.keys(dir.changes)).toEqual(['a']);
|
||||
}));
|
||||
|
||||
it('should only evaluate methods once - #10639', () => {
|
||||
TestBed.configureTestingModule({declarations: [MyCountingComp]});
|
||||
@ -333,8 +333,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(fixture.debugElement.childNodes.length).toBe(0);
|
||||
});
|
||||
|
||||
modifiedInIvy('Comment node order changed') &&
|
||||
it('should allow empty embedded templates', () => {
|
||||
modifiedInIvy('Comment node order changed')
|
||||
.it('should allow empty embedded templates', () => {
|
||||
@Component({template: '<ng-template [ngIf]="true"></ng-template>'})
|
||||
class MyComp {
|
||||
}
|
||||
@ -351,37 +351,36 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should support @ContentChild and @Input on the same property for static queries',
|
||||
() => {
|
||||
@Directive({selector: 'test'})
|
||||
class Test {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@Input() @ContentChild(TemplateRef) tpl !: TemplateRef<any>;
|
||||
}
|
||||
fixmeIvy('unknown').it(
|
||||
'should support @ContentChild and @Input on the same property for static queries', () => {
|
||||
@Directive({selector: 'test'})
|
||||
class Test {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@Input() @ContentChild(TemplateRef) tpl !: TemplateRef<any>;
|
||||
}
|
||||
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
template: `
|
||||
@Component({
|
||||
selector: 'my-app',
|
||||
template: `
|
||||
<test></test><br>
|
||||
<test><ng-template>Custom as a child</ng-template></test><br>
|
||||
<ng-template #custom>Custom as a binding</ng-template>
|
||||
<test [tpl]="custom"></test><br>
|
||||
`
|
||||
})
|
||||
class App {
|
||||
}
|
||||
})
|
||||
class App {
|
||||
}
|
||||
|
||||
const fixture =
|
||||
TestBed.configureTestingModule({declarations: [App, Test]}).createComponent(App);
|
||||
fixture.detectChanges();
|
||||
const fixture =
|
||||
TestBed.configureTestingModule({declarations: [App, Test]}).createComponent(App);
|
||||
fixture.detectChanges();
|
||||
|
||||
const testDirs =
|
||||
fixture.debugElement.queryAll(By.directive(Test)).map(el => el.injector.get(Test));
|
||||
expect(testDirs[0].tpl).toBeUndefined();
|
||||
expect(testDirs[1].tpl).toBeDefined();
|
||||
expect(testDirs[2].tpl).toBeDefined();
|
||||
});
|
||||
const testDirs =
|
||||
fixture.debugElement.queryAll(By.directive(Test)).map(el => el.injector.get(Test));
|
||||
expect(testDirs[0].tpl).toBeUndefined();
|
||||
expect(testDirs[1].tpl).toBeDefined();
|
||||
expect(testDirs[2].tpl).toBeDefined();
|
||||
});
|
||||
|
||||
it('should not add ng-version for dynamically created components', () => {
|
||||
@Component({template: ''})
|
||||
|
@ -52,8 +52,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
afterEach(() => { getDOM().log = originalLog; });
|
||||
|
||||
describe('events', () => {
|
||||
fixmeIvy('FW-787: Exception in template parsing leaves TestBed in corrupted state') &&
|
||||
it('should disallow binding to attr.on*', () => {
|
||||
fixmeIvy('FW-787: Exception in template parsing leaves TestBed in corrupted state')
|
||||
.it('should disallow binding to attr.on*', () => {
|
||||
const template = `<div [attr.onclick]="ctxProp"></div>`;
|
||||
TestBed.overrideComponent(SecuredComponent, {set: {template}});
|
||||
|
||||
@ -62,8 +62,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
/Binding to event attribute 'onclick' is disallowed for security reasons, please use \(click\)=.../);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-787: Exception in template parsing leaves TestBed in corrupted state') &&
|
||||
it('should disallow binding to on* with NO_ERRORS_SCHEMA', () => {
|
||||
fixmeIvy('FW-787: Exception in template parsing leaves TestBed in corrupted state')
|
||||
.it('should disallow binding to on* with NO_ERRORS_SCHEMA', () => {
|
||||
const template = `<div [onclick]="ctxProp"></div>`;
|
||||
TestBed.overrideComponent(SecuredComponent, {set: {template}}).configureTestingModule({
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
@ -75,8 +75,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
});
|
||||
|
||||
fixmeIvy(
|
||||
'FW-786: Element properties and directive inputs are not distinguished for sanitisation purposes') &&
|
||||
it('should disallow binding to on* unless it is consumed by a directive', () => {
|
||||
'FW-786: Element properties and directive inputs are not distinguished for sanitisation purposes')
|
||||
.it('should disallow binding to on* unless it is consumed by a directive', () => {
|
||||
const template = `<div [onPrefixedProp]="ctxProp" [onclick]="ctxProp"></div>`;
|
||||
TestBed.overrideComponent(SecuredComponent, {set: {template}}).configureTestingModule({
|
||||
schemas: [NO_ERRORS_SCHEMA]
|
||||
@ -173,8 +173,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
checkEscapeOfHrefProperty(fixture, true);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-785: Host bindings are not sanitised') &&
|
||||
it('should escape unsafe properties if they are used in host bindings', () => {
|
||||
fixmeIvy('FW-785: Host bindings are not sanitised')
|
||||
.it('should escape unsafe properties if they are used in host bindings', () => {
|
||||
@Directive({selector: '[dirHref]'})
|
||||
class HrefDirective {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@ -190,8 +190,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
checkEscapeOfHrefProperty(fixture, false);
|
||||
});
|
||||
|
||||
fixmeIvy('FW-785: Host bindings are not sanitised') &&
|
||||
it('should escape unsafe attributes if they are used in host bindings', () => {
|
||||
fixmeIvy('FW-785: Host bindings are not sanitised')
|
||||
.it('should escape unsafe attributes if they are used in host bindings', () => {
|
||||
@Directive({selector: '[dirHref]'})
|
||||
class HrefDirective {
|
||||
// TODO(issue/24571): remove '!'.
|
||||
@ -227,8 +227,8 @@ function declareTests(config?: {useJit: boolean}) {
|
||||
expect(getDOM().getStyle(e, 'background')).not.toContain('javascript');
|
||||
});
|
||||
|
||||
fixmeIvy('FW-787: Exception in template parsing leaves TestBed in corrupted state') &&
|
||||
it('should escape unsafe SVG attributes', () => {
|
||||
fixmeIvy('FW-787: Exception in template parsing leaves TestBed in corrupted state')
|
||||
.it('should escape unsafe SVG attributes', () => {
|
||||
const template = `<svg:circle [xlink:href]="ctxProp">Text</svg:circle>`;
|
||||
TestBed.overrideComponent(SecuredComponent, {set: {template}});
|
||||
|
||||
|
@ -102,167 +102,167 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
function declareTests(
|
||||
{ngUrl, templateDecorator}:
|
||||
{ngUrl: string, templateDecorator: (template: string) => { [key: string]: any }}) {
|
||||
fixmeIvy('unknown') &&
|
||||
it('should use the right source url in html parse errors', fakeAsync(() => {
|
||||
@Component({...templateDecorator('<div>\n </error>')})
|
||||
class MyComp {
|
||||
}
|
||||
fixmeIvy('unknown').it(
|
||||
'should use the right source url in html parse errors', fakeAsync(() => {
|
||||
@Component({...templateDecorator('<div>\n </error>')})
|
||||
class MyComp {
|
||||
}
|
||||
|
||||
expect(() => compileAndCreateComponent(MyComp))
|
||||
.toThrowError(new RegExp(
|
||||
`Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:2`));
|
||||
}));
|
||||
expect(() => compileAndCreateComponent(MyComp))
|
||||
.toThrowError(
|
||||
new RegExp(`Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:2`));
|
||||
}));
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should use the right source url in template parse errors', fakeAsync(() => {
|
||||
@Component({...templateDecorator('<div>\n <div unknown="{{ctxProp}}"></div>')})
|
||||
class MyComp {
|
||||
}
|
||||
fixmeIvy('unknown').it(
|
||||
'should use the right source url in template parse errors', fakeAsync(() => {
|
||||
@Component({...templateDecorator('<div>\n <div unknown="{{ctxProp}}"></div>')})
|
||||
class MyComp {
|
||||
}
|
||||
|
||||
expect(() => compileAndCreateComponent(MyComp))
|
||||
.toThrowError(new RegExp(
|
||||
`Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:7`));
|
||||
}));
|
||||
expect(() => compileAndCreateComponent(MyComp))
|
||||
.toThrowError(
|
||||
new RegExp(`Template parse errors[\\s\\S]*${ngUrl.replace('$', '\\$')}@1:7`));
|
||||
}));
|
||||
|
||||
fixmeIvy('unknown') && it('should create a sourceMap for templates', fakeAsync(() => {
|
||||
const template = `Hello World!`;
|
||||
fixmeIvy('unknown').it('should create a sourceMap for templates', fakeAsync(() => {
|
||||
const template = `Hello World!`;
|
||||
|
||||
@Component({...templateDecorator(template)})
|
||||
class MyComp {
|
||||
}
|
||||
@Component({...templateDecorator(template)})
|
||||
class MyComp {
|
||||
}
|
||||
|
||||
compileAndCreateComponent(MyComp);
|
||||
compileAndCreateComponent(MyComp);
|
||||
|
||||
const sourceMap =
|
||||
getSourceMap('ng:///DynamicTestModule/MyComp.ngfactory.js');
|
||||
expect(sourceMap.sources).toEqual([
|
||||
'ng:///DynamicTestModule/MyComp.ngfactory.js', ngUrl
|
||||
]);
|
||||
expect(sourceMap.sourcesContent).toEqual([' ', template]);
|
||||
}));
|
||||
const sourceMap =
|
||||
getSourceMap('ng:///DynamicTestModule/MyComp.ngfactory.js');
|
||||
expect(sourceMap.sources).toEqual([
|
||||
'ng:///DynamicTestModule/MyComp.ngfactory.js', ngUrl
|
||||
]);
|
||||
expect(sourceMap.sourcesContent).toEqual([' ', template]);
|
||||
}));
|
||||
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should report source location for di errors', fakeAsync(() => {
|
||||
const template = `<div>\n <div someDir></div></div>`;
|
||||
fixmeIvy('unknown').it(
|
||||
'should report source location for di errors', fakeAsync(() => {
|
||||
const template = `<div>\n <div someDir></div></div>`;
|
||||
|
||||
@Component({...templateDecorator(template)})
|
||||
class MyComp {
|
||||
}
|
||||
@Component({...templateDecorator(template)})
|
||||
class MyComp {
|
||||
}
|
||||
|
||||
@Directive({selector: '[someDir]'})
|
||||
class SomeDir {
|
||||
constructor() { throw new Error('Test'); }
|
||||
}
|
||||
@Directive({selector: '[someDir]'})
|
||||
class SomeDir {
|
||||
constructor() { throw new Error('Test'); }
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [SomeDir]});
|
||||
let error: any;
|
||||
try {
|
||||
compileAndCreateComponent(MyComp);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
// The error should be logged from the element
|
||||
expect(getSourcePositionForStack(getErrorLoggerStack(error))).toEqual({
|
||||
line: 2,
|
||||
column: 4,
|
||||
source: ngUrl,
|
||||
});
|
||||
}));
|
||||
TestBed.configureTestingModule({declarations: [SomeDir]});
|
||||
let error: any;
|
||||
try {
|
||||
compileAndCreateComponent(MyComp);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
// The error should be logged from the element
|
||||
expect(getSourcePositionForStack(getErrorLoggerStack(error))).toEqual({
|
||||
line: 2,
|
||||
column: 4,
|
||||
source: ngUrl,
|
||||
});
|
||||
}));
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should report di errors with multiple elements and directives', fakeAsync(() => {
|
||||
const template = `<div someDir></div><div someDir="throw"></div>`;
|
||||
fixmeIvy('unknown').it(
|
||||
'should report di errors with multiple elements and directives', fakeAsync(() => {
|
||||
const template = `<div someDir></div><div someDir="throw"></div>`;
|
||||
|
||||
@Component({...templateDecorator(template)})
|
||||
class MyComp {
|
||||
}
|
||||
@Component({...templateDecorator(template)})
|
||||
class MyComp {
|
||||
}
|
||||
|
||||
@Directive({selector: '[someDir]'})
|
||||
class SomeDir {
|
||||
constructor(@Attribute('someDir') someDir: string) {
|
||||
if (someDir === 'throw') {
|
||||
throw new Error('Test');
|
||||
}
|
||||
}
|
||||
}
|
||||
@Directive({selector: '[someDir]'})
|
||||
class SomeDir {
|
||||
constructor(@Attribute('someDir') someDir: string) {
|
||||
if (someDir === 'throw') {
|
||||
throw new Error('Test');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
TestBed.configureTestingModule({declarations: [SomeDir]});
|
||||
let error: any;
|
||||
try {
|
||||
compileAndCreateComponent(MyComp);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
// The error should be logged from the 2nd-element
|
||||
expect(getSourcePositionForStack(getErrorLoggerStack(error))).toEqual({
|
||||
line: 1,
|
||||
column: 19,
|
||||
source: ngUrl,
|
||||
});
|
||||
}));
|
||||
TestBed.configureTestingModule({declarations: [SomeDir]});
|
||||
let error: any;
|
||||
try {
|
||||
compileAndCreateComponent(MyComp);
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
// The error should be logged from the 2nd-element
|
||||
expect(getSourcePositionForStack(getErrorLoggerStack(error))).toEqual({
|
||||
line: 1,
|
||||
column: 19,
|
||||
source: ngUrl,
|
||||
});
|
||||
}));
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should report source location for binding errors', fakeAsync(() => {
|
||||
const template = `<div>\n <span [title]="createError()"></span></div>`;
|
||||
fixmeIvy('unknown').it(
|
||||
'should report source location for binding errors', fakeAsync(() => {
|
||||
const template = `<div>\n <span [title]="createError()"></span></div>`;
|
||||
|
||||
@Component({...templateDecorator(template)})
|
||||
class MyComp {
|
||||
createError() { throw new Error('Test'); }
|
||||
}
|
||||
@Component({...templateDecorator(template)})
|
||||
class MyComp {
|
||||
createError() { throw new Error('Test'); }
|
||||
}
|
||||
|
||||
const comp = compileAndCreateComponent(MyComp);
|
||||
const comp = compileAndCreateComponent(MyComp);
|
||||
|
||||
let error: any;
|
||||
try {
|
||||
comp.detectChanges();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
// the stack should point to the binding
|
||||
expect(getSourcePositionForStack(error.stack)).toEqual({
|
||||
line: 2,
|
||||
column: 12,
|
||||
source: ngUrl,
|
||||
});
|
||||
// The error should be logged from the element
|
||||
expect(getSourcePositionForStack(getErrorLoggerStack(error))).toEqual({
|
||||
line: 2,
|
||||
column: 4,
|
||||
source: ngUrl,
|
||||
});
|
||||
}));
|
||||
let error: any;
|
||||
try {
|
||||
comp.detectChanges();
|
||||
} catch (e) {
|
||||
error = e;
|
||||
}
|
||||
// the stack should point to the binding
|
||||
expect(getSourcePositionForStack(error.stack)).toEqual({
|
||||
line: 2,
|
||||
column: 12,
|
||||
source: ngUrl,
|
||||
});
|
||||
// The error should be logged from the element
|
||||
expect(getSourcePositionForStack(getErrorLoggerStack(error))).toEqual({
|
||||
line: 2,
|
||||
column: 4,
|
||||
source: ngUrl,
|
||||
});
|
||||
}));
|
||||
|
||||
fixmeIvy('unknown') &&
|
||||
it('should report source location for event errors', fakeAsync(() => {
|
||||
const template = `<div>\n <span (click)="createError()"></span></div>`;
|
||||
fixmeIvy('unknown').it(
|
||||
'should report source location for event errors', fakeAsync(() => {
|
||||
const template = `<div>\n <span (click)="createError()"></span></div>`;
|
||||
|
||||
@Component({...templateDecorator(template)})
|
||||
class MyComp {
|
||||
createError() { throw new Error('Test'); }
|
||||
}
|
||||
@Component({...templateDecorator(template)})
|
||||
class MyComp {
|
||||
createError() { throw new Error('Test'); }
|
||||
}
|
||||
|
||||
const comp = compileAndCreateComponent(MyComp);
|
||||
const comp = compileAndCreateComponent(MyComp);
|
||||
|
||||
let error: any;
|
||||
const errorHandler = TestBed.get(ErrorHandler);
|
||||
spyOn(errorHandler, 'handleError').and.callFake((e: any) => error = e);
|
||||
comp.debugElement.children[0].children[0].triggerEventHandler('click', 'EVENT');
|
||||
expect(error).toBeTruthy();
|
||||
// the stack should point to the binding
|
||||
expect(getSourcePositionForStack(error.stack)).toEqual({
|
||||
line: 2,
|
||||
column: 12,
|
||||
source: ngUrl,
|
||||
});
|
||||
// The error should be logged from the element
|
||||
expect(getSourcePositionForStack(getErrorLoggerStack(error))).toEqual({
|
||||
line: 2,
|
||||
column: 4,
|
||||
source: ngUrl,
|
||||
});
|
||||
let error: any;
|
||||
const errorHandler = TestBed.get(ErrorHandler);
|
||||
spyOn(errorHandler, 'handleError').and.callFake((e: any) => error = e);
|
||||
comp.debugElement.children[0].children[0].triggerEventHandler('click', 'EVENT');
|
||||
expect(error).toBeTruthy();
|
||||
// the stack should point to the binding
|
||||
expect(getSourcePositionForStack(error.stack)).toEqual({
|
||||
line: 2,
|
||||
column: 12,
|
||||
source: ngUrl,
|
||||
});
|
||||
// The error should be logged from the element
|
||||
expect(getSourcePositionForStack(getErrorLoggerStack(error))).toEqual({
|
||||
line: 2,
|
||||
column: 4,
|
||||
source: ngUrl,
|
||||
});
|
||||
|
||||
}));
|
||||
}));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(instance.dep instanceof Dep).toBeTruthy();
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should not inject deps from sibling root elements', () => {
|
||||
fixmeIvy('unknown').it('should not inject deps from sibling root elements', () => {
|
||||
const rootElNodes = [
|
||||
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(1, NodeFlags.None, null, 0, Dep, []),
|
||||
@ -181,7 +181,7 @@ import {fixmeIvy} from '@angular/private/testing';
|
||||
expect(instance.dep instanceof Dep).toBeTruthy();
|
||||
});
|
||||
|
||||
fixmeIvy('unknown') && it('should throw for missing dependencies', () => {
|
||||
fixmeIvy('unknown').it('should throw for missing dependencies', () => {
|
||||
expect(() => createAndGetRootNodes(compViewDef([
|
||||
elementDef(0, NodeFlags.None, null, null, 1, 'span'),
|
||||
directiveDef(1, NodeFlags.None, null, 0, SomeService, ['nonExistingDep'])
|
||||
|
Reference in New Issue
Block a user