/** * @license * Copyright Google Inc. All Rights Reserved. * * 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 {MockData} from './test_utils'; export const toh = { 'foo.ts': `export * from './app/app.component.ts';`, app: { 'app.component.ts': `import { Component } from '@angular/core'; export class Hero { id: number; name: string; } @Component({ selector: 'my-app', template: \`~{empty} <~{start-tag}h~{start-tag-after-h}1~{start-tag-h1} ~{h1-after-space}>~{h1-content} {{~{sub-start}title~{sub-end}}} ~{after-h1}

{{~{h2-hero}hero.~{h2-name}name}} details!

{{~{label-hero}hero.~{label-id}id}}
&~{entity-amp}amp; \` }) export class AppComponent { title = 'Tour of Heroes'; hero: Hero = { id: 1, name: 'Windstorm' }; private internal: string; }`, 'main.ts': ` import { NgModule } from '@angular/core'; import { CommonModule } from '@angular/common'; import { FormsModule } from '@angular/forms'; import { AppComponent } from './app.component'; import { CaseIncompleteOpen, CaseMissingClosing, CaseUnknown, Pipes, TemplateReference, NoValueAttribute, AttributeBinding, StringModel, NumberModel, PropertyBinding, EventBinding, TwoWayBinding, EmptyInterpolation, ForOfEmpty, ForLetIEqual, ForOfLetEmpty, ForUsingComponent, References, TestComponent} from './parsing-cases'; import { WrongFieldReference, WrongSubFieldReference, PrivateReference, ExpectNumericType, LowercasePipe } from './expression-cases'; import { UnknownPeople, UnknownEven, UnknownTrackBy } from './ng-for-cases'; import { ShowIf } from './ng-if-cases'; @NgModule({ imports: [CommonModule, FormsModule], declarations: [AppComponent, CaseIncompleteOpen, CaseMissingClosing, CaseUnknown, Pipes, TemplateReference, NoValueAttribute, AttributeBinding, StringModel, NumberModel, PropertyBinding, EventBinding, TwoWayBinding, EmptyInterpolation, ForOfEmpty, ForOfLetEmpty, ForLetIEqual, ForUsingComponent, References, TestComponent, WrongFieldReference, WrongSubFieldReference, PrivateReference, ExpectNumericType, UnknownPeople, UnknownEven, UnknownTrackBy, ShowIf, LowercasePipe] }) export class AppModule {} declare function bootstrap(v: any): void; bootstrap(AppComponent); `, 'parsing-cases.ts': ` import {Component, Directive, Input, Output, EventEmitter} from '@angular/core'; import {Hero} from './app.component'; @Component({template: '

Some <~{incomplete-open-lt}a~{incomplete-open-a} ~{incomplete-open-attr} text

'}) export class CaseIncompleteOpen {} @Component({template: '

Some ~{missing-closing} text

'}) export class CaseMissingClosing {} @Component({template: '

Some text

'}) export class CaseUnknown {} @Component({template: '

{{data | ~{before-pipe}lowe~{in-pipe}rcase~{after-pipe} }}'}) export class Pipes { data = 'Some string'; } @Component({template: '

'}) export class NoValueAttribute {} @Component({template: '

'}) export class AttributeBinding { test: string; } @Component({template: '

'}) export class PropertyBinding { test: string; } @Component({template: '

'}) export class EventBinding { test: string; modelChanged() {} } @Component({template: '

'}) export class TwoWayBinding { test: string; } @Directive({selector: '[string-model]'}) export class StringModel { @Input() model: string; @Output() modelChanged: EventEmitter; } @Directive({selector: '[number-model]'}) export class NumberModel { @Input('inputAlias') model: number; @Output('outputAlias') modelChanged: EventEmitter; } interface Person { name: string; age: number } @Component({template: '
'}) export class ForOfEmpty {} @Component({template: '
'}) export class ForOfLetEmpty {} @Component({template: '
'}) export class ForLetIEqual {} @Component({template: '
Name: {{~{for-interp-person}person.~{for-interp-name}name}}Age: {{person.~{for-interp-age}age}}
'}) export class ForUsingComponent { people: Person[]; } @Component({template: '
{{~{test-comp-content}}} {{test1.~{test-comp-after-test}name}} {{div.~{test-comp-after-div}.innerText}}
'}) export class References {} @Component({selector: 'test-comp', template: '
Testing: {{name}}
'}) export class TestComponent { «@Input('ΔtcNameΔ') name = 'test';» «@Output('ΔtestΔ') testEvent = new EventEmitter();» } @Component({templateUrl: 'test.ng'}) export class TemplateReference { title = 'Some title'; hero: Hero = { id: 1, name: 'Windstorm' }; anyValue: any; myClick(event: any) { } } @Component({template: '{{~{empty-interpolation}}}'}) export class EmptyInterpolation { title = 'Some title'; subTitle = 'Some sub title'; } `, 'expression-cases.ts': ` import {Component} from '@angular/core'; export interface Person { name: string; age: number; } @Component({template: '{{~{foo}foo~{foo-end}}}'}) export class WrongFieldReference { bar = 'bar'; } @Component({template: '{{~{nam}person.nam~{nam-end}}}'}) export class WrongSubFieldReference { person: Person = { name: 'Bob', age: 23 }; } @Component({template: '{{~{myField}myField~{myField-end}}}'}) export class PrivateReference { private myField = 'My Field'; } @Component({template: '{{~{mod}"a" ~{mod-end}% 2}}'}) export class ExpectNumericType {} @Component({template: '{{ (name | lowercase).~{string-pipe}substring }}'}) export class LowercasePipe { name: string; } `, 'ng-for-cases.ts': ` import {Component} from '@angular/core'; export interface Person { name: string; age: number; } @Component({template: '
{{person.name}}
'}) export class UnknownPeople {} @Component({template: '
{{person.name}}
'}) export class UnknownEven { people: Person[]; } @Component({template: '
{{person.name}}
'}) export class UnknownTrackBy { people: Person[]; } `, 'ng-if-cases.ts': ` import {Component} from '@angular/core'; @Component({template: '
Showing now!
'}) export class ShowIf { show = false; } `, 'test.ng': `~{empty} <~{start-tag}h~{start-tag-after-h}1~{start-tag-h1} ~{h1-after-space}>~{h1-content} {{~{sub-start}title~{sub-end}}} ~{after-h1}

{{~{h2-hero}hero.~{h2-name}name}} details!

{{~{label-hero}hero.~{label-id}id}}
&~{entity-amp}amp; ` } };