2017-04-26 12:24:42 -04:00
|
|
|
/**
|
|
|
|
* @license
|
2020-05-19 15:08:49 -04:00
|
|
|
* Copyright Google LLC All Rights Reserved.
|
2017-04-26 12:24:42 -04:00
|
|
|
*
|
|
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
|
|
* found in the LICENSE file at https://angular.io/license
|
|
|
|
*/
|
|
|
|
|
|
|
|
import {Component} from '@angular/core';
|
|
|
|
import {TestBed} from '@angular/core/testing';
|
2020-04-07 15:43:43 -04:00
|
|
|
import {platformServerTesting, ServerTestingModule} from '@angular/platform-server/testing';
|
2017-04-26 12:24:42 -04:00
|
|
|
|
2020-04-07 15:43:43 -04:00
|
|
|
import {expectInstanceCreated, SomeDep, SomeDirective, SomeModule, SomePipe, SomePrivateComponent, SomeService} from '../src/jit_summaries';
|
2017-04-26 12:24:42 -04:00
|
|
|
import {SomeModuleNgSummary} from '../src/jit_summaries.ngsummary';
|
|
|
|
|
|
|
|
describe('Jit Summaries', () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
TestBed.initTestEnvironment(ServerTestingModule, platformServerTesting(), SomeModuleNgSummary);
|
|
|
|
});
|
|
|
|
|
2020-04-07 15:43:43 -04:00
|
|
|
afterEach(() => {
|
|
|
|
TestBed.resetTestEnvironment();
|
|
|
|
});
|
2017-04-26 12:24:42 -04:00
|
|
|
|
|
|
|
it('should use directive metadata from summaries', () => {
|
|
|
|
@Component({template: '<div someDir></div>'})
|
|
|
|
class TestComp {
|
|
|
|
}
|
|
|
|
|
|
|
|
TestBed.configureTestingModule({providers: [SomeDep], declarations: [TestComp, SomeDirective]})
|
|
|
|
.createComponent(TestComp);
|
|
|
|
expectInstanceCreated(SomeDirective);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should use pipe metadata from summaries', () => {
|
|
|
|
@Component({template: '{{1 | somePipe}}'})
|
|
|
|
class TestComp {
|
|
|
|
}
|
|
|
|
|
|
|
|
TestBed.configureTestingModule({providers: [SomeDep], declarations: [TestComp, SomePipe]})
|
|
|
|
.createComponent(TestComp);
|
|
|
|
expectInstanceCreated(SomePipe);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should use Service metadata from summaries', () => {
|
|
|
|
TestBed.configureTestingModule({
|
|
|
|
providers: [SomeService, SomeDep],
|
|
|
|
});
|
2019-08-28 19:22:36 -04:00
|
|
|
TestBed.inject(SomeService);
|
2017-04-26 12:24:42 -04:00
|
|
|
expectInstanceCreated(SomeService);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should use NgModule metadata from summaries', () => {
|
|
|
|
@Component({template: '<div someDir>{{1 | somePipe}}</div>'})
|
|
|
|
class TestComp {
|
|
|
|
constructor(service: SomeService) {}
|
|
|
|
}
|
|
|
|
|
|
|
|
TestBed
|
|
|
|
.configureTestingModule(
|
|
|
|
{providers: [SomeDep], declarations: [TestComp], imports: [SomeModule]})
|
|
|
|
.createComponent(TestComp);
|
|
|
|
|
|
|
|
expectInstanceCreated(SomeModule);
|
|
|
|
expectInstanceCreated(SomeDirective);
|
|
|
|
expectInstanceCreated(SomePipe);
|
|
|
|
expectInstanceCreated(SomeService);
|
|
|
|
});
|
|
|
|
|
|
|
|
it('should allow to create private components from imported NgModule summaries', () => {
|
|
|
|
TestBed.configureTestingModule({providers: [SomeDep], imports: [SomeModule]})
|
|
|
|
.createComponent(SomePrivateComponent);
|
|
|
|
expectInstanceCreated(SomePrivateComponent);
|
|
|
|
});
|
2019-08-28 19:22:36 -04:00
|
|
|
});
|