test: fix existing tests by removing usage of obsolete stuff like component level directives, AsyncCompleter and TestComponentBuilder

This commit is contained in:
Igor Minar
2016-08-19 12:51:01 -07:00
parent 939d318242
commit 3c2b2ff332
46 changed files with 251 additions and 326 deletions
@@ -8,7 +8,7 @@
import {Component} from '@angular/core';
@Component({selector: 'my-comp', template: '<div></div>', directives: [NextComp]})
@Component({selector: 'my-comp', template: '<div></div>'})
export class MultipleComponentsMyComp {
}
@@ -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;
@@ -32,8 +32,7 @@ export class CompWithProviders {
template: `
<input #a>{{a.value}}
<div *ngIf="true">{{a.value}}</div>
`,
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 {
}
@@ -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,
@@ -14,8 +14,7 @@ export class CompWithNgContent {
@Component({
selector: 'main',
template: '<comp-with-proj><span greeting="Hello world!"></span></comp-with-proj>',
directives: [CompWithNgContent]
template: '<comp-with-proj><span greeting="Hello world!"></span></comp-with-proj>'
})
export class ProjectingComp {
}
@@ -13,11 +13,8 @@ import {Component, Directive, QueryList, ViewChild, ViewChildren} from '@angular
export class CompForChildQuery {
}
@Component({
selector: 'comp-with-child-query',
template: '<comp-for-child-query></comp-for-child-query>',
directives: [CompForChildQuery]
})
@Component(
{selector: 'comp-with-child-query', template: '<comp-for-child-query></comp-for-child-query>'})
export class CompWithChildQuery {
@ViewChild(CompForChildQuery) child: CompForChildQuery;
@ViewChildren(CompForChildQuery) children: QueryList<CompForChildQuery>;
@@ -29,7 +26,6 @@ export class DirectiveForQuery {
@Component({
selector: 'comp-with-directive-child',
directives: [DirectiveForQuery, NgFor],
template: `<div>
<div *ngFor="let data of divData" directive-for-query>{{data}}</div>
</div>`
+1 -1
View File
@@ -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),
@@ -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);
@@ -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 <div *ngIf="hero">\n <h2>{{hero.name}} details!</h2>\n <div><label>id: </label>{{hero.id}}</div>\n <div>\n <label>name: </label>\n <input [(ngModel)]="hero.name" placeholder="name"/>\n </div>\n </div>\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 { }
`,