fix(compiler): walk third party modules (#12453)
fixes #11889 fixes #12428
This commit is contained in:

committed by
Igor Minar

parent
bfc97ff2cd
commit
a838aba756
@ -7,6 +7,7 @@
|
||||
*/
|
||||
import './init';
|
||||
|
||||
import {ComponentUsingThirdParty} from '../src/comp_using_3rdp';
|
||||
import {MainModule} from '../src/module';
|
||||
import {CompUsingLibModuleDirectiveAndPipe, CompUsingRootModuleDirectiveAndPipe, SOME_TOKEN, ServiceUsingLibModule, SomeLibModule, SomeService} from '../src/module_fixtures';
|
||||
|
||||
@ -15,9 +16,9 @@ import {createComponent, createModule} from './util';
|
||||
describe('NgModule', () => {
|
||||
it('should support providers', () => {
|
||||
const moduleRef = createModule();
|
||||
expect(moduleRef.instance instanceof MainModule).toBe(true);
|
||||
expect(moduleRef.injector.get(MainModule) instanceof MainModule).toBe(true);
|
||||
expect(moduleRef.injector.get(SomeService) instanceof SomeService).toBe(true);
|
||||
expect(moduleRef.instance instanceof MainModule).toEqual(true);
|
||||
expect(moduleRef.injector.get(MainModule) instanceof MainModule).toEqual(true);
|
||||
expect(moduleRef.injector.get(SomeService) instanceof SomeService).toEqual(true);
|
||||
});
|
||||
|
||||
it('should support entryComponents components', () => {
|
||||
@ -26,7 +27,7 @@ describe('NgModule', () => {
|
||||
CompUsingRootModuleDirectiveAndPipe);
|
||||
expect(cf.componentType).toBe(CompUsingRootModuleDirectiveAndPipe);
|
||||
const compRef = cf.create(moduleRef.injector);
|
||||
expect(compRef.instance instanceof CompUsingRootModuleDirectiveAndPipe).toBe(true);
|
||||
expect(compRef.instance instanceof CompUsingRootModuleDirectiveAndPipe).toEqual(true);
|
||||
});
|
||||
|
||||
it('should support entryComponents via the ANALYZE_FOR_ENTRY_COMPONENTS provider and function providers in components',
|
||||
@ -42,12 +43,30 @@ describe('NgModule', () => {
|
||||
]);
|
||||
});
|
||||
|
||||
describe('third-party modules', () => {
|
||||
// https://github.com/angular/angular/issues/11889
|
||||
it('should support third party entryComponents components', () => {
|
||||
const fixture = createComponent(ComponentUsingThirdParty);
|
||||
const thirdPComps = fixture.nativeElement.children;
|
||||
expect(thirdPComps[0].children[0].children[0].data).toEqual('3rdP-component');
|
||||
expect(thirdPComps[1].children[0].children[0].data).toEqual('other-3rdP-component');
|
||||
});
|
||||
|
||||
// https://github.com/angular/angular/issues/12428
|
||||
it('should support third party directives', () => {
|
||||
const fixture = createComponent(ComponentUsingThirdParty);
|
||||
const debugElement = fixture.debugElement;
|
||||
fixture.detectChanges();
|
||||
expect(debugElement.children[0].properties['title']).toEqual('from 3rd party');
|
||||
});
|
||||
});
|
||||
|
||||
it('should support module directives and pipes', () => {
|
||||
const compFixture = createComponent(CompUsingRootModuleDirectiveAndPipe);
|
||||
compFixture.detectChanges();
|
||||
|
||||
const debugElement = compFixture.debugElement;
|
||||
expect(debugElement.children[0].properties['title']).toBe('transformed someValue');
|
||||
expect(debugElement.children[0].properties['title']).toEqual('transformed someValue');
|
||||
});
|
||||
|
||||
it('should support module directives and pipes on lib modules', () => {
|
||||
@ -55,10 +74,10 @@ describe('NgModule', () => {
|
||||
compFixture.detectChanges();
|
||||
|
||||
const debugElement = compFixture.debugElement;
|
||||
expect(debugElement.children[0].properties['title']).toBe('transformed someValue');
|
||||
expect(debugElement.children[0].properties['title']).toEqual('transformed someValue');
|
||||
|
||||
expect(debugElement.injector.get(SomeLibModule) instanceof SomeLibModule).toBe(true);
|
||||
expect(debugElement.injector.get(SomeLibModule) instanceof SomeLibModule).toEqual(true);
|
||||
expect(debugElement.injector.get(ServiceUsingLibModule) instanceof ServiceUsingLibModule)
|
||||
.toBe(true);
|
||||
.toEqual(true);
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user