diff --git a/modules/@angular/common/test/directives/ng_class_spec.ts b/modules/@angular/common/test/directives/ng_class_spec.ts index 4861d3de5b..4c4bcda6a5 100644 --- a/modules/@angular/common/test/directives/ng_class_spec.ts +++ b/modules/@angular/common/test/directives/ng_class_spec.ts @@ -378,7 +378,7 @@ export function main() { }); } -@Component({selector: 'test-cmp', directives: [NgClass, NgFor], template: ''}) +@Component({selector: 'test-cmp', template: ''}) class TestComponent { condition: boolean = true; items: any[]; diff --git a/modules/@angular/common/test/directives/ng_for_spec.ts b/modules/@angular/common/test/directives/ng_for_spec.ts index 7035ea19fb..c9997388e0 100644 --- a/modules/@angular/common/test/directives/ng_for_spec.ts +++ b/modules/@angular/common/test/directives/ng_for_spec.ts @@ -6,10 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgFor, NgIf} from '@angular/common'; +import {CommonModule} from '@angular/common'; import {Component, ContentChild, TemplateRef} from '@angular/core'; import {TestBed, async} from '@angular/core/testing'; -import {ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {By} from '@angular/platform-browser/src/dom/debug/by'; import {expect} from '@angular/platform-browser/testing/matchers'; @@ -23,9 +22,8 @@ export function main() { '
{{item.toString()}};
'; beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [TestComponent, ComponentUsingTestComponent], - }); + TestBed.configureTestingModule( + {declarations: [TestComponent, ComponentUsingTestComponent], imports: [CommonModule]}); }); it('should reflect initial elements', async(() => { @@ -420,7 +418,7 @@ class Foo { toString() { return 'foo'; } } -@Component({selector: 'test-cmp', directives: [NgFor, NgIf], template: ''}) +@Component({selector: 'test-cmp', template: ''}) class TestComponent { @ContentChild(TemplateRef) contentTpl: TemplateRef; items: any; @@ -430,7 +428,7 @@ class TestComponent { trackByContext(): void { thisArg = this; } } -@Component({selector: 'outer-cmp', directives: [TestComponent], template: ''}) +@Component({selector: 'outer-cmp', template: ''}) class ComponentUsingTestComponent { items: any; constructor() { this.items = [1, 2]; } diff --git a/modules/@angular/common/test/directives/ng_if_spec.ts b/modules/@angular/common/test/directives/ng_if_spec.ts index aba59c417b..79b5b2428a 100644 --- a/modules/@angular/common/test/directives/ng_if_spec.ts +++ b/modules/@angular/common/test/directives/ng_if_spec.ts @@ -6,10 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgIf} from '@angular/common'; +import {CommonModule} from '@angular/common'; import {Component} from '@angular/core'; import {TestBed, async} from '@angular/core/testing'; -import {beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {expect} from '@angular/platform-browser/testing/matchers'; @@ -17,9 +16,7 @@ export function main() { describe('ngIf directive', () => { beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [TestComponent], - }); + TestBed.configureTestingModule({declarations: [TestComponent], imports: [CommonModule]}); }); it('should work in a template attribute', async(() => { @@ -171,7 +168,7 @@ export function main() { }); } -@Component({selector: 'test-cmp', directives: [NgIf], template: ''}) +@Component({selector: 'test-cmp', template: ''}) class TestComponent { booleanCondition: boolean; nestedBooleanCondition: boolean; diff --git a/modules/@angular/common/test/directives/ng_plural_spec.ts b/modules/@angular/common/test/directives/ng_plural_spec.ts index e8644ae89b..c827b784c9 100644 --- a/modules/@angular/common/test/directives/ng_plural_spec.ts +++ b/modules/@angular/common/test/directives/ng_plural_spec.ts @@ -6,10 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgLocalization, NgPlural, NgPluralCase} from '@angular/common'; +import {CommonModule, NgLocalization} from '@angular/common'; import {Component, Injectable} from '@angular/core'; import {TestBed, async} from '@angular/core/testing'; -import {beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {expect} from '@angular/platform-browser/testing/matchers'; export function main() { @@ -18,7 +17,8 @@ export function main() { beforeEach(() => { TestBed.configureTestingModule({ declarations: [TestComponent], - providers: [{provide: NgLocalization, useClass: TestLocalization}] + providers: [{provide: NgLocalization, useClass: TestLocalization}], + imports: [CommonModule] }); }); @@ -139,7 +139,7 @@ class TestLocalization extends NgLocalization { } } -@Component({selector: 'test-cmp', directives: [NgPlural, NgPluralCase], template: ''}) +@Component({selector: 'test-cmp', template: ''}) class TestComponent { switchValue: number = null; } diff --git a/modules/@angular/common/test/directives/ng_style_spec.ts b/modules/@angular/common/test/directives/ng_style_spec.ts index e7b95f2089..375b60dd9f 100644 --- a/modules/@angular/common/test/directives/ng_style_spec.ts +++ b/modules/@angular/common/test/directives/ng_style_spec.ts @@ -6,12 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {beforeEach, ddescribe, xdescribe, describe, expect, iit, it, xit,} from '@angular/core/testing/testing_internal'; -import {async, TestBed, ComponentFixture} from '@angular/core/testing'; - +import {CommonModule} from '@angular/common'; import {Component} from '@angular/core'; - -import {NgStyle} from '@angular/common/src/directives/ng_style'; +import {ComponentFixture, TestBed, async} from '@angular/core/testing'; function expectNativeEl(fixture: ComponentFixture) { return expect(fixture.debugElement.children[0].nativeElement); @@ -21,9 +18,7 @@ export function main() { describe('binding to CSS styles', () => { beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [TestComponent], - }); + TestBed.configureTestingModule({declarations: [TestComponent], imports: [CommonModule]}); }); it('should add styles specified in an object literal', async(() => { @@ -154,7 +149,7 @@ export function main() { }); } -@Component({selector: 'test-cmp', directives: [NgStyle], template: ''}) +@Component({selector: 'test-cmp', template: ''}) class TestComponent { expr: any; } diff --git a/modules/@angular/common/test/directives/ng_switch_spec.ts b/modules/@angular/common/test/directives/ng_switch_spec.ts index 2885308a7d..38b1455ede 100644 --- a/modules/@angular/common/test/directives/ng_switch_spec.ts +++ b/modules/@angular/common/test/directives/ng_switch_spec.ts @@ -6,19 +6,16 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgSwitch, NgSwitchCase, NgSwitchDefault} from '@angular/common'; +import {CommonModule} from '@angular/common'; import {Component} from '@angular/core'; import {TestBed, async} from '@angular/core/testing'; -import {beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {expect} from '@angular/platform-browser/testing/matchers'; export function main() { describe('switch', () => { beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [TestComponent], - }); + TestBed.configureTestingModule({declarations: [TestComponent], imports: [CommonModule]}); }); describe('switch value changes', () => { @@ -149,8 +146,7 @@ export function main() { }); } -@Component( - {selector: 'test-cmp', directives: [NgSwitch, NgSwitchCase, NgSwitchDefault], template: ''}) +@Component({selector: 'test-cmp', template: ''}) class TestComponent { switchValue: any; when1: any; diff --git a/modules/@angular/common/test/directives/ng_template_outlet_spec.ts b/modules/@angular/common/test/directives/ng_template_outlet_spec.ts index ececac1f28..f38eb9c8be 100644 --- a/modules/@angular/common/test/directives/ng_template_outlet_spec.ts +++ b/modules/@angular/common/test/directives/ng_template_outlet_spec.ts @@ -6,19 +6,17 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgTemplateOutlet} from '@angular/common'; +import {CommonModule} from '@angular/common'; import {Component, ContentChildren, Directive, QueryList, TemplateRef} from '@angular/core'; import {TestBed, async} from '@angular/core/testing'; -import {beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {expect} from '@angular/platform-browser/testing/matchers'; export function main() { describe('insert', () => { beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [TestComponent], - }); + TestBed.configureTestingModule( + {declarations: [TestComponent, CaptureTplRefs], imports: [CommonModule]}); }); it('should do nothing if templateRef is null', async(() => { @@ -160,7 +158,7 @@ class CaptureTplRefs { @ContentChildren(TemplateRef) tplRefs: QueryList>; } -@Component({selector: 'test-cmp', directives: [NgTemplateOutlet, CaptureTplRefs], template: ''}) +@Component({selector: 'test-cmp', template: ''}) class TestComponent { currentTplRef: TemplateRef; context: any = {foo: 'bar'}; diff --git a/modules/@angular/common/test/directives/non_bindable_spec.ts b/modules/@angular/common/test/directives/non_bindable_spec.ts index a70e01cf27..ba925aeef9 100644 --- a/modules/@angular/common/test/directives/non_bindable_spec.ts +++ b/modules/@angular/common/test/directives/non_bindable_spec.ts @@ -9,7 +9,6 @@ import {Component, Directive} from '@angular/core'; import {ElementRef} from '@angular/core/src/linker/element_ref'; import {TestBed, async} from '@angular/core/testing'; -import {beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {expect} from '@angular/platform-browser/testing/matchers'; @@ -18,7 +17,7 @@ export function main() { beforeEach(() => { TestBed.configureTestingModule({ - declarations: [TestComponent], + declarations: [TestComponent, TestDirective], }); }); @@ -58,7 +57,7 @@ class TestDirective { constructor(el: ElementRef) { getDOM().addClass(el.nativeElement, 'compiled'); } } -@Component({selector: 'test-cmp', directives: [TestDirective], template: ''}) +@Component({selector: 'test-cmp', template: ''}) class TestComponent { text: string; constructor() { this.text = 'foo'; } diff --git a/modules/@angular/common/test/pipes/json_pipe_spec.ts b/modules/@angular/common/test/pipes/json_pipe_spec.ts index ac782f5480..edb6fa9ca0 100644 --- a/modules/@angular/common/test/pipes/json_pipe_spec.ts +++ b/modules/@angular/common/test/pipes/json_pipe_spec.ts @@ -6,10 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {JsonPipe} from '@angular/common'; +import {CommonModule, JsonPipe} from '@angular/common'; import {Component} from '@angular/core'; import {TestBed, async} from '@angular/core/testing'; -import {afterEach, beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {expect} from '@angular/platform-browser/testing/matchers'; import {Json, StringWrapper} from '../../src/facade/lang'; @@ -56,10 +55,13 @@ export function main() { describe('integration', () => { + @Component({selector: 'test-comp', template: '{{data | json}}'}) + class TestComp { + data: any; + } + beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [TestComp], - }); + TestBed.configureTestingModule({declarations: [TestComp], imports: [CommonModule]}); }); it('should work with mutable objects', async(() => { @@ -77,8 +79,3 @@ export function main() { }); }); } - -@Component({selector: 'test-comp', template: '{{data | json}}', pipes: [JsonPipe]}) -class TestComp { - data: any; -} diff --git a/modules/@angular/common/test/pipes/slice_pipe_spec.ts b/modules/@angular/common/test/pipes/slice_pipe_spec.ts index 9a9c72a742..74f5789262 100644 --- a/modules/@angular/common/test/pipes/slice_pipe_spec.ts +++ b/modules/@angular/common/test/pipes/slice_pipe_spec.ts @@ -6,10 +6,9 @@ * found in the LICENSE file at https://angular.io/license */ -import {SlicePipe} from '@angular/common'; +import {CommonModule, SlicePipe} from '@angular/common'; import {Component} from '@angular/core'; import {TestBed, async} from '@angular/core/testing'; -import {afterEach, beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {browserDetection} from '@angular/platform-browser/testing/browser_util'; import {expect} from '@angular/platform-browser/testing/matchers'; @@ -88,10 +87,14 @@ export function main() { }); describe('integration', () => { + + @Component({selector: 'test-comp', template: '{{(data | slice:1).join(",") }}'}) + class TestComp { + data: any; + } + beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [TestComp], - }); + TestBed.configureTestingModule({declarations: [TestComp], imports: [CommonModule]}); }); it('should work with mutable arrays', async(() => { @@ -108,8 +111,3 @@ export function main() { }); }); } - -@Component({selector: 'test-comp', template: '{{(data | slice:1).join(",") }}', pipes: [SlicePipe]}) -class TestComp { - data: any; -} diff --git a/modules/@angular/compiler-cli/integrationtest/src/a/multiple_components.ts b/modules/@angular/compiler-cli/integrationtest/src/a/multiple_components.ts index 3204a30527..eb76422ee6 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/a/multiple_components.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/a/multiple_components.ts @@ -8,7 +8,7 @@ import {Component} from '@angular/core'; -@Component({selector: 'my-comp', template: '
', directives: [NextComp]}) +@Component({selector: 'my-comp', template: '
'}) export class MultipleComponentsMyComp { } diff --git a/modules/@angular/compiler-cli/integrationtest/src/basic.ts b/modules/@angular/compiler-cli/integrationtest/src/basic.ts index 5a39f83126..c34c5a5fd5 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/basic.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/basic.ts @@ -17,7 +17,6 @@ import {MultipleComponentsMyComp} from './a/multiple_components'; templateUrl: './basic.html', styles: ['.red { color: red }'], styleUrls: ['./basic.css'], - directives: [MultipleComponentsMyComp, FORM_DIRECTIVES, NgIf, NgFor] }) export class BasicComp { ctxProp: string; diff --git a/modules/@angular/compiler-cli/integrationtest/src/features.ts b/modules/@angular/compiler-cli/integrationtest/src/features.ts index 5889360517..c6f3da13a2 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/features.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/features.ts @@ -32,8 +32,7 @@ export class CompWithProviders { template: ` {{a.value}}
{{a.value}}
- `, - directives: [wrapInArray(common.NgIf)] + ` }) export class CompWithReferences { } @@ -51,6 +50,6 @@ export class CompUsingPipes { export class CompUsingCustomElements { } -@NgModule({schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: [CompUsingCustomElements]}) +@NgModule({schemas: [CUSTOM_ELEMENTS_SCHEMA], declarations: wrapInArray(CompUsingCustomElements)}) export class ModuleUsingCustomElements { } diff --git a/modules/@angular/compiler-cli/integrationtest/src/module.ts b/modules/@angular/compiler-cli/integrationtest/src/module.ts index f0794d18f4..596230e1ea 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/module.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/module.ts @@ -11,20 +11,22 @@ import {FormsModule} from '@angular/forms'; import {BrowserModule} from '@angular/platform-browser'; import {MdButtonModule} from '@angular2-material/button'; +import {MultipleComponentsMyComp, NextComp} from './a/multiple_components'; import {AnimateCmp} from './animate'; import {BasicComp} from './basic'; import {CompWithAnalyzeEntryComponentsProvider, CompWithEntryComponents} from './entry_components'; import {CompUsingPipes, CompWithProviders, CompWithReferences, ModuleUsingCustomElements} from './features'; import {CompUsingRootModuleDirectiveAndPipe, SomeDirectiveInRootModule, SomePipeInRootModule, SomeService, someLibModuleWithProviders} from './module_fixtures'; -import {ProjectingComp} from './projection'; -import {CompWithChildQuery, CompWithDirectiveChild} from './queries'; +import {CompWithNgContent, ProjectingComp} from './projection'; +import {CompForChildQuery, CompWithChildQuery, CompWithDirectiveChild, DirectiveForQuery} from './queries'; @NgModule({ declarations: [ - SomeDirectiveInRootModule, SomePipeInRootModule, AnimateCmp, BasicComp, CompWithEntryComponents, - CompWithAnalyzeEntryComponentsProvider, ProjectingComp, CompWithChildQuery, - CompWithDirectiveChild, CompUsingRootModuleDirectiveAndPipe, CompWithProviders, - CompWithReferences, CompUsingPipes + SomeDirectiveInRootModule, SomePipeInRootModule, AnimateCmp, BasicComp, CompForChildQuery, + CompWithEntryComponents, CompWithAnalyzeEntryComponentsProvider, ProjectingComp, + CompWithChildQuery, CompWithDirectiveChild, CompWithNgContent, + CompUsingRootModuleDirectiveAndPipe, CompWithProviders, CompWithReferences, CompUsingPipes, + MultipleComponentsMyComp, DirectiveForQuery, NextComp ], imports: [ BrowserModule, FormsModule, someLibModuleWithProviders(), ModuleUsingCustomElements, diff --git a/modules/@angular/compiler-cli/integrationtest/src/projection.ts b/modules/@angular/compiler-cli/integrationtest/src/projection.ts index 9a979f6a65..35a5c05851 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/projection.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/projection.ts @@ -14,8 +14,7 @@ export class CompWithNgContent { @Component({ selector: 'main', - template: '', - directives: [CompWithNgContent] + template: '' }) export class ProjectingComp { } diff --git a/modules/@angular/compiler-cli/integrationtest/src/queries.ts b/modules/@angular/compiler-cli/integrationtest/src/queries.ts index 76a92d93cd..e031e8e9b0 100644 --- a/modules/@angular/compiler-cli/integrationtest/src/queries.ts +++ b/modules/@angular/compiler-cli/integrationtest/src/queries.ts @@ -13,11 +13,8 @@ import {Component, Directive, QueryList, ViewChild, ViewChildren} from '@angular export class CompForChildQuery { } -@Component({ - selector: 'comp-with-child-query', - template: '', - directives: [CompForChildQuery] -}) +@Component( + {selector: 'comp-with-child-query', template: ''}) export class CompWithChildQuery { @ViewChild(CompForChildQuery) child: CompForChildQuery; @ViewChildren(CompForChildQuery) children: QueryList; @@ -29,7 +26,6 @@ export class DirectiveForQuery { @Component({ selector: 'comp-with-directive-child', - directives: [DirectiveForQuery, NgFor], template: `
{{data}}
` diff --git a/modules/@angular/compiler-cli/src/codegen.ts b/modules/@angular/compiler-cli/src/codegen.ts index 8e597f1173..1ac0e26f62 100644 --- a/modules/@angular/compiler-cli/src/codegen.ts +++ b/modules/@angular/compiler-cli/src/codegen.ts @@ -166,7 +166,7 @@ export class CodeGenerator { const resolver = new CompileMetadataResolver( new compiler.NgModuleResolver(staticReflector), new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector), - config, console, elementSchemaRegistry, staticReflector); + elementSchemaRegistry, staticReflector); // TODO(vicb): do not pass cliOptions.i18nFormat here const offlineCompiler = new compiler.OfflineCompiler( resolver, normalizer, tmplParser, new StyleCompiler(urlResolver), new ViewCompiler(config), diff --git a/modules/@angular/compiler-cli/src/extract_i18n.ts b/modules/@angular/compiler-cli/src/extract_i18n.ts index d966cb33ad..ec8caab37b 100644 --- a/modules/@angular/compiler-cli/src/extract_i18n.ts +++ b/modules/@angular/compiler-cli/src/extract_i18n.ts @@ -178,7 +178,7 @@ export class Extractor { const resolver = new CompileMetadataResolver( new compiler.NgModuleResolver(staticReflector), new compiler.DirectiveResolver(staticReflector), new compiler.PipeResolver(staticReflector), - config, console, elementSchemaRegistry, staticReflector); + elementSchemaRegistry, staticReflector); const offlineCompiler = new compiler.OfflineCompiler( resolver, normalizer, tmplParser, new StyleCompiler(urlResolver), new ViewCompiler(config), new NgModuleCompiler(), new TypeScriptEmitter(reflectorHost), null, null); diff --git a/modules/@angular/compiler-cli/test/static_reflector_spec.ts b/modules/@angular/compiler-cli/test/static_reflector_spec.ts index d1dcc11af8..682f7a847d 100644 --- a/modules/@angular/compiler-cli/test/static_reflector_spec.ts +++ b/modules/@angular/compiler-cli/test/static_reflector_spec.ts @@ -8,7 +8,6 @@ import {StaticReflector, StaticReflectorHost, StaticSymbol} from '@angular/compiler-cli/src/static_reflector'; import {HostListenerMetadata, animate, group, keyframes, sequence, state, style, transition, trigger} from '@angular/core'; -import {beforeEach, ddescribe, describe, expect, iit, it} from '@angular/core/testing/testing_internal'; import {ListWrapper} from '@angular/facade/src/collection'; import {isBlank} from '@angular/facade/src/lang'; import {MetadataCollector} from '@angular/tsc-wrapped'; @@ -65,8 +64,6 @@ describe('StaticReflector', () => { expect(annotations.length).toEqual(1); let annotation = annotations[0]; expect(annotation.selector).toEqual('my-hero-detail'); - expect(annotation.directives).toEqual([[host.findDeclaration( - 'angular2/src/common/directives/ng_for', 'NgFor')]]); expect(annotation.animations).toEqual([trigger('myAnimation', [ state('state1', style({'background': 'white'})), transition( @@ -596,13 +593,6 @@ class MockReflectorHost implements StaticReflectorHost { 'selector': 'my-hero-detail', 'template': '\n
\n

{{hero.name}} details!

\n
{{hero.id}}
\n
\n \n \n
\n
\n', - 'directives': [ - { - '__symbolic': 'reference', - 'name': 'FORM_DIRECTIVES', - 'module': 'angular2/src/common/forms-deprecated/directives' - } - ], 'animations': [{ '__symbolic': 'call', 'expression': { @@ -755,7 +745,7 @@ class MockReflectorHost implements StaticReflectorHost { }, arguments: [ { - directives: [ + entryComponents: [ { __symbolic: 'reference', module: 'src/error-references', @@ -957,14 +947,14 @@ class MockReflectorHost implements StaticReflectorHost { @Component({ selector: 'my-component', - directives: [someFunction([NgIf])] + entryComponents: [someFunction([NgIf])] }) export class MyComponent {} @someFunction() @Component({ selector: 'my-component', - directives: [NgIf] + entryComponents: [NgIf] }) export class MyOtherComponent { } `, diff --git a/modules/@angular/compiler/test/i18n/integration_spec.ts b/modules/@angular/compiler/test/i18n/integration_spec.ts index 425bd91ee0..25a42d664a 100644 --- a/modules/@angular/compiler/test/i18n/integration_spec.ts +++ b/modules/@angular/compiler/test/i18n/integration_spec.ts @@ -6,26 +6,20 @@ * found in the LICENSE file at https://angular.io/license */ -import {DirectiveResolver, ResourceLoader, i18n} from '@angular/compiler'; -import {MockDirectiveResolver} from '@angular/compiler/testing'; -import {Compiler, Component, DebugElement, Injector, TRANSLATIONS, TRANSLATIONS_FORMAT} from '@angular/core'; -import {TestBed, fakeAsync} from '@angular/core/testing'; -import {beforeEach, TestComponentBuilder, ddescribe, describe, iit, inject, it, xdescribe, xit,} from '@angular/core/testing/testing_internal'; -import {expect} from '@angular/platform-browser/testing/matchers'; -import {By} from '@angular/platform-browser/src/dom/debug/by'; -import {SpyResourceLoader} from '../spies'; import {NgLocalization} from '@angular/common'; +import {ResourceLoader, i18n} from '@angular/compiler'; +import {Component, DebugElement, TRANSLATIONS, TRANSLATIONS_FORMAT} from '@angular/core'; +import {TestBed, async} from '@angular/core/testing'; +import {By} from '@angular/platform-browser/src/dom/debug/by'; import {stringifyElement} from '@angular/platform-browser/testing/browser_util'; +import {expect} from '@angular/platform-browser/testing/matchers'; + +import {SpyResourceLoader} from '../spies'; export function main() { describe('i18n integration spec', () => { - let compiler: Compiler; - let xhr: SpyResourceLoader; - let tcb: TestComponentBuilder; - let dirResolver: MockDirectiveResolver; - let injector: Injector; - beforeEach(() => { + beforeEach(async(() => { TestBed.configureCompiler({ providers: [ {provide: ResourceLoader, useClass: SpyResourceLoader}, @@ -34,21 +28,15 @@ export function main() { {provide: TRANSLATIONS_FORMAT, useValue: 'xtb'}, ] }); - }); - beforeEach(fakeAsync(inject( - [Compiler, TestComponentBuilder, ResourceLoader, DirectiveResolver, Injector], - (_compiler: Compiler, _tcb: TestComponentBuilder, _xhr: SpyResourceLoader, - _dirResolver: MockDirectiveResolver, _injector: Injector) => { - compiler = _compiler; - tcb = _tcb; - xhr = _xhr; - dirResolver = _dirResolver; - injector = _injector; - }))); + TestBed.configureTestingModule({declarations: [I18nComponent]}); + + TestBed.compileComponents(); + })); + it('translate templates', () => { - const tb = tcb.createSync(I18nComponent); + const tb = TestBed.createComponent(I18nComponent); const cmp = tb.componentInstance; const el = tb.debugElement; diff --git a/modules/@angular/compiler/test/metadata_resolver_spec.ts b/modules/@angular/compiler/test/metadata_resolver_spec.ts index 99e31d1b6b..59e5ca0d20 100644 --- a/modules/@angular/compiler/test/metadata_resolver_spec.ts +++ b/modules/@angular/compiler/test/metadata_resolver_spec.ts @@ -6,14 +6,11 @@ * found in the LICENSE file at https://angular.io/license */ -import {CompilerConfig} from '@angular/compiler/src/config'; import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/testing/test_bindings'; import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, Component, Directive, DoCheck, Injectable, NgModule, OnChanges, OnDestroy, OnInit, Pipe, SimpleChanges, ViewEncapsulation} from '@angular/core'; import {LIFECYCLE_HOOKS_VALUES} from '@angular/core/src/metadata/lifecycle_hooks'; -import {TestBed} from '@angular/core/testing'; -import {afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; +import {TestBed, inject} from '@angular/core/testing'; -import {CompileNgModuleMetadata} from '../src/compile_metadata'; import {stringify} from '../src/facade/lang'; import {CompileMetadataResolver} from '../src/metadata_resolver'; @@ -190,7 +187,6 @@ class ComponentWithoutModuleId { encapsulation: ViewEncapsulation.Emulated, styles: ['someStyle'], styleUrls: ['someStyleUrl'], - directives: [SomeDirective], interpolation: ['{{', '}}'] }) class ComponentWithEverything implements OnChanges, diff --git a/modules/@angular/core/test/animation/animation_integration_spec.ts b/modules/@angular/core/test/animation/animation_integration_spec.ts index 17c7d2b63c..2424f7ae7f 100644 --- a/modules/@angular/core/test/animation/animation_integration_spec.ts +++ b/modules/@angular/core/test/animation/animation_integration_spec.ts @@ -6,7 +6,7 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgIf} from '@angular/common'; +import {CommonModule} from '@angular/common'; import {AnimationDriver} from '@angular/platform-browser/src/dom/animation_driver'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {MockAnimationDriver} from '@angular/platform-browser/testing/mock_animation_driver'; @@ -15,11 +15,10 @@ import {DEFAULT_STATE} from '../../src/animation/animation_constants'; import {AnimationKeyframe} from '../../src/animation/animation_keyframe'; import {AnimationPlayer} from '../../src/animation/animation_player'; import {AnimationStyles} from '../../src/animation/animation_styles'; -import {AUTO_STYLE, AnimationEntryMetadata, animate, group, keyframes, sequence, state, style, transition, trigger} from '../../src/animation/metadata'; +import {AUTO_STYLE, animate, group, keyframes, sequence, state, style, transition, trigger} from '../../src/animation/metadata'; import {isPresent} from '../../src/facade/lang'; import {TestBed, fakeAsync, flushMicrotasks} from '../../testing'; import {MockAnimationPlayer} from '../../testing/mock_animation_player'; -import {beforeEach, ddescribe, describe, expect, iit, it, xdescribe, xit} from '../../testing/testing_internal'; export function main() { describe('jit', () => { declareTests({useJit: true}); }); @@ -32,7 +31,8 @@ function declareTests({useJit}: {useJit: boolean}) { TestBed.configureCompiler({useJit: useJit}); TestBed.configureTestingModule({ declarations: [DummyLoadingCmp, DummyIfCmp], - providers: [{provide: AnimationDriver, useClass: MockAnimationDriver}] + providers: [{provide: AnimationDriver, useClass: MockAnimationDriver}], + imports: [CommonModule] }); }); @@ -1639,7 +1639,6 @@ class InnerContentTrackingAnimationPlayer extends MockAnimationPlayer { @Component({ selector: 'if-cmp', - directives: [NgIf], animations: [trigger('myAnimation', [])], template: `
diff --git a/modules/@angular/core/test/directive_lifecycle_integration_spec.ts b/modules/@angular/core/test/directive_lifecycle_integration_spec.ts index 865a6106b5..a38d7f2710 100644 --- a/modules/@angular/core/test/directive_lifecycle_integration_spec.ts +++ b/modules/@angular/core/test/directive_lifecycle_integration_spec.ts @@ -8,14 +8,12 @@ import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, DoCheck, OnChanges, OnInit} from '@angular/core'; import {Component, Directive} from '@angular/core/src/metadata'; -import {ViewMetadata} from '@angular/core/src/metadata/view'; -import {TestBed} from '@angular/core/testing'; -import {AsyncTestCompleter, Log, TestComponentBuilder, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; +import {TestBed, inject} from '@angular/core/testing'; +import {Log} from '@angular/core/testing/testing_internal'; export function main() { describe('directive lifecycle integration spec', () => { let log: Log; - beforeEachProviders(() => { return [Log]; }); beforeEach(() => { TestBed @@ -24,7 +22,8 @@ export function main() { LifecycleCmp, LifecycleDir, MyComp5, - ] + ], + providers: [Log] }) .overrideComponent(MyComp5, {set: {template: '
'}}); }); diff --git a/modules/@angular/core/test/linker/change_detection_integration_spec.ts b/modules/@angular/core/test/linker/change_detection_integration_spec.ts index cf1d962527..1b93f63253 100644 --- a/modules/@angular/core/test/linker/change_detection_integration_spec.ts +++ b/modules/@angular/core/test/linker/change_detection_integration_spec.ts @@ -6,15 +6,12 @@ * found in the LICENSE file at https://angular.io/license */ -import {AsyncPipe, NgFor} from '@angular/common'; import {ElementSchemaRegistry} from '@angular/compiler/src/schema/element_schema_registry'; import {MockSchemaRegistry} from '@angular/compiler/testing'; import {TEST_COMPILER_PROVIDERS} from '@angular/compiler/testing/test_bindings'; import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, ChangeDetectionStrategy, ChangeDetectorRef, Component, ComponentMetadata, DebugElement, Directive, DoCheck, Injectable, Input, OnChanges, OnDestroy, OnInit, Output, Pipe, PipeTransform, RenderComponentType, Renderer, RootRenderer, SimpleChange, SimpleChanges, TemplateRef, Type, ViewContainerRef, WrappedValue, forwardRef} from '@angular/core'; import {DebugDomRenderer} from '@angular/core/src/debug/debug_renderer'; -import {ViewMetadata} from '@angular/core/src/metadata/view'; import {ComponentFixture, TestBed, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing'; -import {TestComponentBuilder, afterEach, beforeEach, beforeEachProviders, ddescribe, describe, expect, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {By} from '@angular/platform-browser/src/dom/debug/by'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {DomRootRenderer} from '@angular/platform-browser/src/dom/dom_renderer'; diff --git a/modules/@angular/core/test/linker/entry_components_integration_spec.ts b/modules/@angular/core/test/linker/entry_components_integration_spec.ts index 989a0c78ff..bbfaab2e05 100644 --- a/modules/@angular/core/test/linker/entry_components_integration_spec.ts +++ b/modules/@angular/core/test/linker/entry_components_integration_spec.ts @@ -9,7 +9,7 @@ import {ANALYZE_FOR_ENTRY_COMPONENTS, Component, ComponentFactoryResolver, NoComponentFactoryError, forwardRef} from '@angular/core'; import {TestBed} from '@angular/core/testing'; import {Console} from '../../src/console'; -import {stringify} from '../../src/facade/lang'; + export function main() { describe('jit', () => { declareTests({useJit: true}); }); @@ -44,7 +44,8 @@ function declareTests({useJit}: {useJit: boolean}) { it('should resolve ComponentFactories via ANALYZE_FOR_ENTRY_COMPONENTS', () => { TestBed.resetTestingModule(); - TestBed.configureTestingModule({declarations: [CompWithAnalyzeEntryComponentsProvider]}); + TestBed.configureTestingModule( + {declarations: [CompWithAnalyzeEntryComponentsProvider, NestedChildComp, ChildComp]}); let compFixture = TestBed.createComponent(CompWithAnalyzeEntryComponentsProvider); let mainComp: CompWithAnalyzeEntryComponentsProvider = compFixture.componentInstance; let cfr: ComponentFactoryResolver = diff --git a/modules/@angular/core/test/linker/integration_spec.ts b/modules/@angular/core/test/linker/integration_spec.ts index 01a2661123..0e5e48b95d 100644 --- a/modules/@angular/core/test/linker/integration_spec.ts +++ b/modules/@angular/core/test/linker/integration_spec.ts @@ -6,8 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {AsyncPipe, NgFor, NgIf} from '@angular/common'; -import {Compiler, Host, Inject, Injectable, Injector, NgModule, OnDestroy, OpaqueToken, ReflectiveInjector, SkipSelf, SkipSelfMetadata, forwardRef} from '@angular/core'; +import {CommonModule} from '@angular/common'; +import {ComponentFactory, Host, Inject, Injectable, Injector, NgModule, OnDestroy, OpaqueToken, ReflectiveInjector, SkipSelf, SkipSelfMetadata, forwardRef} from '@angular/core'; import {ChangeDetectionStrategy, ChangeDetectorRef, PipeTransform} from '@angular/core/src/change_detection/change_detection'; import {ComponentFactoryResolver} from '@angular/core/src/linker/component_factory_resolver'; import {ElementRef} from '@angular/core/src/linker/element_ref'; @@ -16,10 +16,8 @@ import {TemplateRef, TemplateRef_} from '@angular/core/src/linker/template_ref'; import {ViewContainerRef} from '@angular/core/src/linker/view_container_ref'; import {EmbeddedViewRef} from '@angular/core/src/linker/view_ref'; import {Attribute, Component, ContentChildren, Directive, HostBinding, HostListener, Input, Output, Pipe} from '@angular/core/src/metadata'; -import {ViewMetadata} from '@angular/core/src/metadata/view'; import {Renderer} from '@angular/core/src/render'; -import {ComponentFixture, TestBed, async, fakeAsync, getTestBed, tick} from '@angular/core/testing'; -import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xdescribe, xit} from '@angular/core/testing/testing_internal'; +import {TestBed, async, fakeAsync, getTestBed, inject, tick} from '@angular/core/testing'; import {getDOM} from '@angular/platform-browser/src/dom/dom_adapter'; import {dispatchEvent, el} from '@angular/platform-browser/testing/browser_util'; import {expect} from '@angular/platform-browser/testing/matchers'; @@ -381,8 +379,12 @@ function declareTests({useJit}: {useJit: boolean}) { }); it('should allow to transplant TemplateRefs into other ViewContainers', () => { - TestBed.configureTestingModule( - {declarations: [MyComp, SomeDirective, CompWithHost, ToolbarComponent, ToolbarPart]}); + TestBed.configureTestingModule({ + declarations: [ + MyComp, SomeDirective, CompWithHost, ToolbarComponent, ToolbarViewContainer, ToolbarPart + ], + imports: [CommonModule] + }); const template = ''; TestBed.overrideComponent(MyComp, {set: {template}}); @@ -523,7 +525,8 @@ function declareTests({useJit}: {useJit: boolean}) { }); it('should be checked when its bindings got updated', () => { - TestBed.configureTestingModule({declarations: [MyComp, [[PushCmp]]]}); + TestBed.configureTestingModule( + {declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]}); const template = ''; TestBed.overrideComponent(MyComp, {set: {template}}); const fixture = TestBed.createComponent(MyComp); @@ -559,7 +562,8 @@ function declareTests({useJit}: {useJit: boolean}) { } it('should be checked when an event is fired', () => { - TestBed.configureTestingModule({declarations: [MyComp, [[PushCmp]]]}); + TestBed.configureTestingModule( + {declarations: [MyComp, PushCmp, EventCmp], imports: [CommonModule]}); const template = ''; TestBed.overrideComponent(MyComp, {set: {template}}); const fixture = TestBed.createComponent(MyComp); @@ -611,7 +615,8 @@ function declareTests({useJit}: {useJit: boolean}) { if (getDOM().supportsDOMEvents()) { it('should be checked when an async pipe requests a check', fakeAsync(() => { - TestBed.configureTestingModule({declarations: [MyComp, [[PushCmpWithAsyncPipe]]]}); + TestBed.configureTestingModule( + {declarations: [MyComp, PushCmpWithAsyncPipe], imports: [CommonModule]}); const template = ''; TestBed.overrideComponent(MyComp, {set: {template}}); const fixture = TestBed.createComponent(MyComp); @@ -670,92 +675,81 @@ function declareTests({useJit}: {useJit: boolean}) { expect(childComponent.myHost).toBeAnInstanceOf(SomeDirective); }); - it('should support events via EventEmitter on regular elements', () => { - TestBed.configureTestingModule( - {declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]}); - inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - const template = '
'; - TestBed.overrideComponent(MyComp, {set: {template}}); - const fixture = TestBed.createComponent(MyComp); + it('should support events via EventEmitter on regular elements', async(() => { + TestBed.configureTestingModule( + {declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]}); + const template = '
'; + TestBed.overrideComponent(MyComp, {set: {template}}); + const fixture = TestBed.createComponent(MyComp); - var tc = fixture.debugElement.children[0]; - var emitter = tc.injector.get(DirectiveEmittingEvent); - var listener = tc.injector.get(DirectiveListeningEvent); + var tc = fixture.debugElement.children[0]; + var emitter = tc.injector.get(DirectiveEmittingEvent); + var listener = tc.injector.get(DirectiveListeningEvent); - expect(listener.msg).toEqual(''); - var eventCount = 0; + expect(listener.msg).toEqual(''); + var 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 !'); - async.done(); - } - } - }); + 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 !'); + })); - it('should support events via EventEmitter on template elements', () => { - TestBed.configureTestingModule( - {declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]}); - inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - const template = ''; - TestBed.overrideComponent(MyComp, {set: {template}}); - const fixture = TestBed.createComponent(MyComp); + it('should support events via EventEmitter on template elements', async(() => { + TestBed.configureTestingModule( + {declarations: [MyComp, DirectiveEmittingEvent, DirectiveListeningEvent]}); + const template = ''; + TestBed.overrideComponent(MyComp, {set: {template}}); + const fixture = TestBed.createComponent(MyComp); - var tc = fixture.debugElement.childNodes[0]; + var tc = fixture.debugElement.childNodes[0]; - var emitter = tc.injector.get(DirectiveEmittingEvent); - var myComp = fixture.debugElement.injector.get(MyComp); - var listener = tc.injector.get(DirectiveListeningEvent); + var emitter = tc.injector.get(DirectiveEmittingEvent); + var myComp = fixture.debugElement.injector.get(MyComp); + var 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 !'); - async.done(); - } - }); + emitter.event.subscribe({ + next: () => { + expect(listener.msg).toEqual('fired !'); + expect(myComp.ctxProp).toEqual('fired !'); + } + }); - emitter.fireEvent('fired !'); - }); - }); + emitter.fireEvent('fired !'); + })); - it('should support [()] syntax', () => { - TestBed.configureTestingModule({declarations: [MyComp, DirectiveWithTwoWayBinding]}); - inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { - const template = '
'; - TestBed.overrideComponent(MyComp, {set: {template}}); - const fixture = TestBed.createComponent(MyComp); - var tc = fixture.debugElement.children[0]; - var dir = tc.injector.get(DirectiveWithTwoWayBinding); + it('should support [()] syntax', async(() => { + TestBed.configureTestingModule({declarations: [MyComp, DirectiveWithTwoWayBinding]}); + const template = '
'; + TestBed.overrideComponent(MyComp, {set: {template}}); + const fixture = TestBed.createComponent(MyComp); + var tc = fixture.debugElement.children[0]; + var dir = tc.injector.get(DirectiveWithTwoWayBinding); - fixture.debugElement.componentInstance.ctxProp = 'one'; - fixture.detectChanges(); + fixture.debugElement.componentInstance.ctxProp = 'one'; + fixture.detectChanges(); - expect(dir.control).toEqual('one'); + expect(dir.control).toEqual('one'); - dir.controlChange.subscribe({ - next: () => { - expect(fixture.debugElement.componentInstance.ctxProp).toEqual('two'); - async.done(); - } - }); + dir.controlChange.subscribe({ + next: () => { expect(fixture.debugElement.componentInstance.ctxProp).toEqual('two'); } + }); - dir.triggerChange('two'); - }); - }); + dir.triggerChange('two'); + })); it('should support render events', () => { TestBed.configureTestingModule({declarations: [MyComp, DirectiveListeningDomEvent]}); @@ -931,8 +925,10 @@ function declareTests({useJit}: {useJit: boolean}) { it('should support custom interpolation', () => { TestBed.configureTestingModule({ - declarations: - [MyComp, ComponentWithCustomInterpolationA, ComponentWithCustomInterpolationB] + declarations: [ + MyComp, ComponentWithCustomInterpolationA, ComponentWithCustomInterpolationB, + ComponentWithDefaultInterpolation + ] }); const template = `
{{ctxProp}}
@@ -1082,7 +1078,7 @@ function declareTests({useJit}: {useJit: boolean}) { class SomeDirective { } - @Component({selector: 'comp', template: '', directives: [SomeDirective]}) + @Component({selector: 'comp', template: ''}) class SomeComponent { } @@ -1091,18 +1087,36 @@ function declareTests({useJit}: {useJit: boolean}) { .toThrowError(`Directive ${stringify(SomeDirective)} has no selector, please add it!`); }); - it('should use a default element name for components without selectors', - inject([Compiler, Injector], (compiler: Compiler, injector: Injector) => { - @Component({template: ''}) - class SomeComponent { - } + it('should use a default element name for components without selectors', () => { + let noSelectorComponentFactory: ComponentFactory; - const compFactory = compiler.compileComponentSync(SomeComponent); - expect(compFactory.selector).toBe('ng-component'); - expect( - getDOM().nodeName(compFactory.create(injector).location.nativeElement).toLowerCase()) - .toEqual('ng-component'); - })); + @Component({template: '----'}) + class NoSelectorComponent { + } + + @Component({selector: 'some-comp', template: '', entryComponents: [NoSelectorComponent]}) + class SomeComponent { + constructor(componentFactoryResolver: ComponentFactoryResolver) { + // grab its own component factory + noSelectorComponentFactory = + componentFactoryResolver.resolveComponentFactory(NoSelectorComponent); + } + } + + TestBed.configureTestingModule({declarations: [SomeComponent, NoSelectorComponent]}); + + // get the factory + TestBed.createComponent(SomeComponent); + + expect(noSelectorComponentFactory.selector).toBe('ng-component'); + expect( + getDOM() + .nodeName( + noSelectorComponentFactory.create(TestBed.get(Injector)).location.nativeElement) + .toLowerCase()) + .toEqual('ng-component'); + + }); }); describe('error handling', () => { @@ -1222,7 +1236,7 @@ function declareTests({useJit}: {useJit: boolean}) { it('should specify a location of an error that happened during change detection (directive property)', () => { - TestBed.configureTestingModule({declarations: [MyComp, ChildComp]}); + TestBed.configureTestingModule({declarations: [MyComp, ChildComp, MyDir]}); const template = ''; TestBed.overrideComponent(MyComp, {set: {template}}); const fixture = TestBed.createComponent(MyComp); @@ -1414,7 +1428,8 @@ function declareTests({useJit}: {useJit: boolean}) { } it('should support defining views in the component decorator', () => { - TestBed.configureTestingModule({declarations: [MyComp, ComponentWithTemplate]}); + TestBed.configureTestingModule( + {declarations: [MyComp, ComponentWithTemplate], imports: [CommonModule]}); const template = ''; TestBed.overrideComponent(MyComp, {set: {template}}); const fixture = TestBed.createComponent(MyComp); @@ -1525,8 +1540,7 @@ class ComponentWithCustomInterpolationA { selector: 'cmp-with-custom-interpolation-b', template: `
{**text%}
()`, - interpolation: ['{**', '%}'], - directives: [ComponentWithDefaultInterpolation] + interpolation: ['{**', '%}'] }) class ComponentWithCustomInterpolationB { text = 'Custom Interpolation B'; @@ -1589,8 +1603,7 @@ class EventCmp { inputs: ['prop'], changeDetection: ChangeDetectionStrategy.OnPush, template: - '{{field}}
', - directives: [EventCmp, NgIf] + '{{field}}
' }) class PushCmp { numberOfChecks: number; @@ -1643,8 +1656,7 @@ class PushCmpWithHostEvent { @Component({ selector: 'push-cmp-with-async', changeDetection: ChangeDetectionStrategy.OnPush, - template: '{{field | async}}', - pipes: [AsyncPipe] + template: '{{field | async}}' }) class PushCmpWithAsyncPipe { numberOfChecks: number = 0; @@ -1661,7 +1673,7 @@ class PushCmpWithAsyncPipe { } } -@Component({selector: 'my-comp', template: '', directives: []}) +@Component({selector: 'my-comp', template: ''}) class MyComp { ctxProp: string; ctxNumProp: number; @@ -1681,7 +1693,6 @@ class MyComp { selector: 'child-cmp', inputs: ['dirProp'], viewProviders: [MyService], - directives: [MyDir], template: '{{ctxProp}}' }) class ChildComp { @@ -1693,7 +1704,7 @@ class ChildComp { } } -@Component({selector: 'child-cmp-no-template', directives: [], template: ''}) +@Component({selector: 'child-cmp-no-template', template: ''}) class ChildCompNoTemplate { ctxProp: string = 'hello'; } @@ -1713,7 +1724,6 @@ class SomeDirectiveMissingAnnotation {} @Component({ selector: 'cmp-with-host', template: '

Component with an injected host

', - directives: [SomeDirective] }) class CompWithHost { myHost: SomeDirective; @@ -1898,7 +1908,6 @@ class ToolbarViewContainer { @Component({ selector: 'toolbar', template: 'TOOLBAR(
)', - directives: [ToolbarViewContainer, NgFor] }) class ToolbarComponent { @ContentChildren(ToolbarPart) query: QueryList; @@ -2013,7 +2022,6 @@ function createParentBus(peb: EventBus) { providers: [ {provide: EventBus, useFactory: createParentBus, deps: [[EventBus, new SkipSelfMetadata()]]} ], - directives: [forwardRef(() => ChildConsumingEventBus)], template: `` }) class ParentProvidingEventBus { @@ -2089,7 +2097,6 @@ class DirectiveThrowingAnError { @Component({ selector: 'component-with-template', - directives: [NgFor], template: `No View Decorator:
{{item}}
` }) class ComponentWithTemplate { diff --git a/modules/@angular/core/test/linker/projection_integration_spec.ts b/modules/@angular/core/test/linker/projection_integration_spec.ts index 15e5cc28d7..d6da817797 100644 --- a/modules/@angular/core/test/linker/projection_integration_spec.ts +++ b/modules/@angular/core/test/linker/projection_integration_spec.ts @@ -450,7 +450,7 @@ export function main() { }); it('should allow to switch the order of nested components via ng-content', () => { - TestBed.configureTestingModule({declarations: [CmpA, CmpB]}); + TestBed.configureTestingModule({declarations: [CmpA, CmpB, CmpD, CmpC]}); TestBed.overrideComponent(MainComp, {set: {template: ``}}); const main = TestBed.createComponent(MainComp); @@ -555,7 +555,7 @@ class SimpleNative1 { class SimpleNative2 { } -@Component({selector: 'empty', template: '', directives: []}) +@Component({selector: 'empty', template: ''}) class Empty { } @@ -670,30 +670,28 @@ class CmpC { } -@Component( - {selector: 'cmp-b', template: ``, directives: [CmpD]}) +@Component({selector: 'cmp-b', template: ``}) class CmpB { } -@Component( - {selector: 'cmp-a', template: ``, directives: [CmpC]}) +@Component({selector: 'cmp-a', template: ``}) class CmpA { } -@Component({selector: 'cmp-b11', template: `{{'b11'}}`, directives: []}) +@Component({selector: 'cmp-b11', template: `{{'b11'}}`}) class CmpB11 { } -@Component({selector: 'cmp-b12', template: `{{'b12'}}`, directives: []}) +@Component({selector: 'cmp-b12', template: `{{'b12'}}`}) class CmpB12 { } -@Component({selector: 'cmp-b21', template: `{{'b21'}}`, directives: []}) +@Component({selector: 'cmp-b21', template: `{{'b21'}}`}) class CmpB21 { } -@Component({selector: 'cmp-b22', template: `{{'b22'}}`, directives: []}) +@Component({selector: 'cmp-b22', template: `{{'b22'}}`}) class CmpB22 { } diff --git a/modules/@angular/core/test/linker/query_integration_spec.ts b/modules/@angular/core/test/linker/query_integration_spec.ts index 4dda3df143..16b6e4d224 100644 --- a/modules/@angular/core/test/linker/query_integration_spec.ts +++ b/modules/@angular/core/test/linker/query_integration_spec.ts @@ -6,10 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgFor, NgIf} from '@angular/common'; import {AfterContentChecked, AfterContentInit, AfterViewChecked, AfterViewInit, Component, ContentChild, ContentChildren, Directive, QueryList, TemplateRef, ViewChild, ViewChildren, ViewContainerRef, asNativeElements} from '@angular/core'; import {TestBed, async} from '@angular/core/testing'; -import {AsyncTestCompleter, TestComponentBuilder, beforeEach, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; import {expect} from '@angular/platform-browser/testing/matchers'; import {isPresent, stringify} from '../../src/facade/lang'; @@ -748,7 +746,7 @@ class NeedsQueryDesc { @ContentChildren(TextDirective, {descendants: true}) query: QueryList; } -@Component({selector: 'needs-query-by-ref-binding', directives: [], template: ''}) +@Component({selector: 'needs-query-by-ref-binding', template: ''}) class NeedsQueryByLabel { @ContentChildren('textLabel', {descendants: true}) query: QueryList; } @@ -758,7 +756,7 @@ class NeedsViewQueryByLabel { @ViewChildren('textLabel') query: QueryList; } -@Component({selector: 'needs-query-by-ref-bindings', directives: [], template: ''}) +@Component({selector: 'needs-query-by-ref-bindings', template: ''}) class NeedsQueryByTwoLabels { @ContentChildren('textLabel1,textLabel2', {descendants: true}) query: QueryList; } diff --git a/modules/@angular/examples/core/pipes/ts/async_pipe/async_pipe_example.ts b/modules/@angular/examples/core/pipes/ts/async_pipe/async_pipe_example.ts index 29cb2e2bed..d8692abfed 100644 --- a/modules/@angular/examples/core/pipes/ts/async_pipe/async_pipe_example.ts +++ b/modules/@angular/examples/core/pipes/ts/async_pipe/async_pipe_example.ts @@ -55,7 +55,6 @@ class Task { @Component({ selector: 'example-app', - directives: [AsyncPipeExample], template: `

AsyncPipe Example

@@ -64,7 +63,8 @@ class Task { export class AppCmp { } -@NgModule({imports: [BrowserModule], bootstrap: [AppCmp]}) +@NgModule( + {declarations: [AsyncPipeExample, AppCmp, Task], imports: [BrowserModule], bootstrap: [AppCmp]}) class AppModule { } diff --git a/modules/@angular/examples/core/pipes/ts/date_pipe/date_pipe_example.ts b/modules/@angular/examples/core/pipes/ts/date_pipe/date_pipe_example.ts index a6f498c924..57ee317b3a 100644 --- a/modules/@angular/examples/core/pipes/ts/date_pipe/date_pipe_example.ts +++ b/modules/@angular/examples/core/pipes/ts/date_pipe/date_pipe_example.ts @@ -26,7 +26,6 @@ export class DatePipeExample { @Component({ selector: 'example-app', - directives: [DatePipeExample], template: `

DatePipe Example

@@ -35,10 +34,10 @@ export class DatePipeExample { export class AppCmp { } -@NgModule({imports: [BrowserModule], bootstrap: [AppCmp]}) +@NgModule({declarations: [DatePipeExample, AppCmp], imports: [BrowserModule], bootstrap: [AppCmp]}) class AppModule { } export function main() { platformBrowserDynamic().bootstrapModule(AppModule); -} \ No newline at end of file +} diff --git a/modules/@angular/examples/core/pipes/ts/json_pipe/json_pipe_example.ts b/modules/@angular/examples/core/pipes/ts/json_pipe/json_pipe_example.ts index 4d5f7fbf7d..23621f8338 100644 --- a/modules/@angular/examples/core/pipes/ts/json_pipe/json_pipe_example.ts +++ b/modules/@angular/examples/core/pipes/ts/json_pipe/json_pipe_example.ts @@ -27,7 +27,6 @@ export class JsonPipeExample { @Component({ selector: 'example-app', - directives: [JsonPipeExample], template: `

JsonPipe Example

@@ -42,4 +41,4 @@ class AppModule { export function main() { platformBrowserDynamic().bootstrapModule(AppModule); -} \ No newline at end of file +} diff --git a/modules/@angular/examples/core/pipes/ts/lowerupper_pipe/lowerupper_pipe_example.ts b/modules/@angular/examples/core/pipes/ts/lowerupper_pipe/lowerupper_pipe_example.ts index e65667425f..a546fc5fc9 100644 --- a/modules/@angular/examples/core/pipes/ts/lowerupper_pipe/lowerupper_pipe_example.ts +++ b/modules/@angular/examples/core/pipes/ts/lowerupper_pipe/lowerupper_pipe_example.ts @@ -27,7 +27,6 @@ export class LowerUpperPipeExample { @Component({ selector: 'example-app', - directives: [LowerUpperPipeExample], template: `

LowercasePipe & UppercasePipe Example

diff --git a/modules/@angular/examples/core/pipes/ts/number_pipe/number_pipe_example.ts b/modules/@angular/examples/core/pipes/ts/number_pipe/number_pipe_example.ts index e5f7247da1..4f07f0cc64 100644 --- a/modules/@angular/examples/core/pipes/ts/number_pipe/number_pipe_example.ts +++ b/modules/@angular/examples/core/pipes/ts/number_pipe/number_pipe_example.ts @@ -56,7 +56,6 @@ export class CurrencyPipeExample { @Component({ selector: 'example-app', - directives: [NumberPipeExample, PercentPipeExample, CurrencyPipeExample], template: `

Numeric Pipe Examples

NumberPipe Example

diff --git a/modules/@angular/examples/core/pipes/ts/slice_pipe/slice_pipe_example.ts b/modules/@angular/examples/core/pipes/ts/slice_pipe/slice_pipe_example.ts index 267a105ef0..bedc3cf025 100644 --- a/modules/@angular/examples/core/pipes/ts/slice_pipe/slice_pipe_example.ts +++ b/modules/@angular/examples/core/pipes/ts/slice_pipe/slice_pipe_example.ts @@ -41,7 +41,6 @@ export class SlicePipeListExample { @Component({ selector: 'example-app', - directives: [SlicePipeListExample, SlicePipeStringExample], template: `

SlicePipe Examples

@@ -57,4 +56,4 @@ class AppModule { export function main() { platformBrowserDynamic().bootstrapModule(AppModule); -} \ No newline at end of file +} diff --git a/modules/@angular/examples/core/ts/metadata/metadata.ts b/modules/@angular/examples/core/ts/metadata/metadata.ts index 836877afd0..20502230f0 100644 --- a/modules/@angular/examples/core/ts/metadata/metadata.ts +++ b/modules/@angular/examples/core/ts/metadata/metadata.ts @@ -11,7 +11,7 @@ import {Attribute, Component, Directive, Pipe} from '@angular/core'; class CustomDirective {}; // #docregion component -@Component({selector: 'greet', template: 'Hello {{name}}!', directives: [CustomDirective]}) +@Component({selector: 'greet', template: 'Hello {{name}}!'}) class Greet { name: string = 'World'; } diff --git a/modules/@angular/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts b/modules/@angular/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts index 0f7a2b6988..5f77c48581 100644 --- a/modules/@angular/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts +++ b/modules/@angular/platform-browser-dynamic/test/resource_loader/resource_loader_cache_spec.ts @@ -8,8 +8,7 @@ import {ResourceLoader, UrlResolver} from '@angular/compiler'; import {BaseException, Component} from '@angular/core'; -import {TestBed, fakeAsync, flushMicrotasks, tick} from '@angular/core/testing'; -import {AsyncTestCompleter, beforeEach, beforeEachProviders, ddescribe, describe, iit, inject, it, xit} from '@angular/core/testing/testing_internal'; +import {TestBed, async, fakeAsync, tick} from '@angular/core/testing'; import {expect} from '@angular/platform-browser/testing/matchers'; import {CachedResourceLoader} from '../../src/resource_loader/resource_loader_cache'; @@ -43,28 +42,30 @@ export function main() { }).toThrowError('CachedResourceLoader: Template cache was not found in $templateCache.'); }); - it('should resolve the Promise with the cached file content on success', - inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { + it('should resolve the Promise with the cached file content on success', async(() => { setTemplateCache({'test.html': '
Hello
'}); resourceLoader = new CachedResourceLoader(); - resourceLoader.get('test.html').then((text) => { - expect(text).toEqual('
Hello
'); - async.done(); - }); + resourceLoader.get('test.html').then((text) => { expect(text).toBe('
Hello
'); }); })); - it('should reject the Promise on failure', - inject([AsyncTestCompleter], (async: AsyncTestCompleter) => { + it('should reject the Promise on failure', async(() => { resourceLoader = new CachedResourceLoader(); resourceLoader.get('unknown.html') .then((text) => { throw new BaseException('Not expected to succeed.'); }) - .catch((error) => { async.done(); }); + .catch((error) => {/** success */}); })); it('should allow fakeAsync Tests to load components with templateUrl synchronously', fakeAsync(() => { + TestBed.configureTestingModule({declarations: [TestComponent]}); + TestBed.compileComponents(); + tick(); + let fixture = TestBed.createComponent(TestComponent); - fixture.detectChanges(); + + // This should initialize the fixture. + tick(); + expect(fixture.debugElement.children[0].nativeElement).toHaveText('Hello'); })); }); diff --git a/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts b/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts index 01d7a4cdac..9348648b1a 100644 --- a/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts +++ b/modules/@angular/platform-browser/test/web_workers/worker/renderer_integration_spec.ts @@ -6,10 +6,8 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgIf} from '@angular/common'; -import {Component, ComponentRef, Injectable, Injector, ReflectiveInjector, getPlatform} from '@angular/core'; +import {Component, ComponentRef, Injectable, Injector} from '@angular/core'; import {DebugDomRootRenderer} from '@angular/core/src/debug/debug_renderer'; -import {ViewMetadata} from '@angular/core/src/metadata/view'; import {RootRenderer} from '@angular/core/src/render/api'; import {TestBed} from '@angular/core/testing'; import {platformBrowserDynamicTesting} from '@angular/platform-browser-dynamic/testing'; @@ -206,7 +204,7 @@ export function main() { } -@Component({selector: 'my-comp', directives: []}) +@Component({selector: 'my-comp'}) @Injectable() class MyComp2 { ctxProp: string; diff --git a/modules/@angular/platform-server/test/integration_spec.ts b/modules/@angular/platform-server/test/integration_spec.ts index b9bc950859..025bcc3ae7 100644 --- a/modules/@angular/platform-server/test/integration_spec.ts +++ b/modules/@angular/platform-server/test/integration_spec.ts @@ -24,7 +24,7 @@ function writeBody(html: string): any { class MyServerApp { } -@NgModule({imports: [ServerModule], declarations: [MyServerApp], bootstrap: [MyServerApp]}) +@NgModule({declarations: [MyServerApp], imports: [ServerModule], bootstrap: [MyServerApp]}) class ExampleModule { } diff --git a/modules/playground/src/hello_world/index.ts b/modules/playground/src/hello_world/index.ts index 80eeadae4d..7f8f9d3022 100644 --- a/modules/playground/src/hello_world/index.ts +++ b/modules/playground/src/hello_world/index.ts @@ -57,6 +57,6 @@ export class HelloCmp { changeGreeting(): void { this.greeting = 'howdy'; } } -@NgModule({bootstrap: [HelloCmp], declarations: [HelloCmp, RedDec], imports: [BrowserModule]}) +@NgModule({declarations: [HelloCmp, RedDec], bootstrap: [HelloCmp], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/playground/src/model_driven_forms/index.ts b/modules/playground/src/model_driven_forms/index.ts index 28b0d6ea88..630f7ae61b 100644 --- a/modules/playground/src/model_driven_forms/index.ts +++ b/modules/playground/src/model_driven_forms/index.ts @@ -158,7 +158,7 @@ class ReactiveForms { @NgModule({ bootstrap: [ReactiveForms], - declarations: [ReactiveForms, ShowError], + declarations: [ShowError, ReactiveForms], imports: [BrowserModule, ReactiveFormsModule] }) class ExampleModule { diff --git a/modules/playground/src/relative_assets/index.ts b/modules/playground/src/relative_assets/index.ts index 25caced54f..43894d02a7 100644 --- a/modules/playground/src/relative_assets/index.ts +++ b/modules/playground/src/relative_assets/index.ts @@ -18,12 +18,11 @@ export function main() { @Component({ selector: 'relative-app', - directives: [MyCmp], template: `component = `, }) export class RelativeApp { } -@NgModule({declarations: [RelativeApp], bootstrap: [RelativeApp], imports: [BrowserModule]}) +@NgModule({declarations: [RelativeApp, MyCmp], bootstrap: [RelativeApp], imports: [BrowserModule]}) class ExampleModule { } diff --git a/modules/playground/src/template_driven_forms/index.ts b/modules/playground/src/template_driven_forms/index.ts index 6d8eb2932e..72d35f1d3d 100644 --- a/modules/playground/src/template_driven_forms/index.ts +++ b/modules/playground/src/template_driven_forms/index.ts @@ -9,7 +9,7 @@ import {NgFor, NgIf} from '@angular/common'; import {Component, Directive, Host, NgModule} from '@angular/core'; import {isPresent, print} from '@angular/core/src/facade/lang'; -import {FORM_DIRECTIVES, FormGroup, NG_VALIDATORS, NgControl, NgForm, Validators} from '@angular/forms'; +import {FormGroup, FormsModule, NG_VALIDATORS, NgControl, NgForm, Validators} from '@angular/forms'; import {BrowserModule} from '@angular/platform-browser'; import {platformBrowserDynamic} from '@angular/platform-browser-dynamic'; @@ -71,8 +71,7 @@ class CreditCardValidator { inputs: ['controlPath: control', 'errorTypes: errors'], template: ` {{errorMessage}} - `, - directives: [NgIf] + ` }) class ShowError { formDir: any /** TODO #9100 */; @@ -157,8 +156,7 @@ class ShowError { - `, - directives: [FORM_DIRECTIVES, NgFor, CreditCardValidator, ShowError] + ` }) class TemplateDrivenForms { model = new CheckoutModel(); @@ -170,9 +168,9 @@ class TemplateDrivenForms { } } @NgModule({ - declarations: [TemplateDrivenForms], + declarations: [TemplateDrivenForms, CreditCardValidator, ShowError], bootstrap: [TemplateDrivenForms], - imports: [BrowserModule] + imports: [BrowserModule, FormsModule] }) class ExampleModule { } diff --git a/modules/playground/src/web_workers/kitchen_sink/index_common.ts b/modules/playground/src/web_workers/kitchen_sink/index_common.ts index 0a2ecf2a93..7aafe6771a 100644 --- a/modules/playground/src/web_workers/kitchen_sink/index_common.ts +++ b/modules/playground/src/web_workers/kitchen_sink/index_common.ts @@ -46,12 +46,7 @@ export class RedDec { // context of the HelloCmp class below. template: `
{{greeting}} world!
-
{{lastKey}}

`, - // All directives used in the template need to be specified. This allows for - // modularity (RedDec can only be used in this template) - // and better tooling (the template can be invalidated if the attribute is - // misspelled). - directives: [RedDec] +
{{lastKey}}

` }) export class HelloCmp { greeting: string; diff --git a/modules/playground/src/web_workers/todo/background_index.ts b/modules/playground/src/web_workers/todo/background_index.ts index 167c6e0e3d..ab1bf02e71 100644 --- a/modules/playground/src/web_workers/todo/background_index.ts +++ b/modules/playground/src/web_workers/todo/background_index.ts @@ -7,12 +7,13 @@ */ import {NgModule} from '@angular/core'; +import {FormsModule} from '@angular/forms'; import {WorkerAppModule} from '@angular/platform-browser'; import {platformWorkerAppDynamic} from '@angular/platform-browser-dynamic'; import {TodoApp} from './index_common'; -@NgModule({imports: [WorkerAppModule], bootstrap: [TodoApp], declarations: [TodoApp]}) +@NgModule({imports: [WorkerAppModule, FormsModule], bootstrap: [TodoApp], declarations: [TodoApp]}) class ExampleModule { } diff --git a/modules/playground/src/web_workers/todo/index_common.ts b/modules/playground/src/web_workers/todo/index_common.ts index 3ece579da5..e8eda99e65 100644 --- a/modules/playground/src/web_workers/todo/index_common.ts +++ b/modules/playground/src/web_workers/todo/index_common.ts @@ -6,18 +6,11 @@ * found in the LICENSE file at https://angular.io/license */ -import {NgFor} from '@angular/common'; import {Component} from '@angular/core'; -import {FORM_DIRECTIVES} from '@angular/forms'; import {Store, Todo, TodoFactory} from './services/TodoStore'; -@Component({ - selector: 'todo-app', - viewProviders: [Store, TodoFactory], - templateUrl: 'todo.html', - directives: [NgFor, FORM_DIRECTIVES] -}) +@Component({selector: 'todo-app', viewProviders: [Store, TodoFactory], templateUrl: 'todo.html'}) export class TodoApp { todoEdit: Todo = null; inputValue: string; diff --git a/modules/playground/src/zippy_component/index.ts b/modules/playground/src/zippy_component/index.ts index 44f1cccd53..5e17f1b225 100644 --- a/modules/playground/src/zippy_component/index.ts +++ b/modules/playground/src/zippy_component/index.ts @@ -21,8 +21,7 @@ import {Zippy} from './app/zippy';
  • {{log}}
- `, - directives: [Zippy] + ` }) class ZippyApp { logs: string[] = []; @@ -30,10 +29,10 @@ class ZippyApp { pushLog(log: string) { this.logs.push(log); } } -@NgModule({declarations: [ZippyApp], bootstrap: [ZippyApp], imports: [BrowserModule]}) +@NgModule({declarations: [ZippyApp, Zippy], bootstrap: [ZippyApp], imports: [BrowserModule]}) class ExampleModule { } export function main() { platformBrowserDynamic().bootstrapModule(ExampleModule); -} \ No newline at end of file +}