test(language-service): remove ng-for-cases.ts (#36470)

This commit removes ng-for-cases.ts and moves all test cases to
inline expressions in TEST_TEMPLATE.

PR Close #36470
This commit is contained in:
Keen Yee Liau 2020-04-06 20:04:56 -07:00 committed by Kara Erickson
parent 1dd0b6cc18
commit 7f28845f58
3 changed files with 15 additions and 62 deletions

View File

@ -274,22 +274,22 @@ describe('diagnostics', () => {
expect(diags).toContain('Expected a number type'); expect(diags).toContain('Expected a number type');
}); });
describe('in ng-for-cases.ts', () => { it('should report an unknown field', () => {
it('should report an unknown field', () => { mockHost.override(TEST_TEMPLATE, `<div *ngFor="let person of people"></div>`);
const diags = ngLS.getSemanticDiagnostics(NG_FOR_CASES).map(d => d.messageText); const diags = ngLS.getSemanticDiagnostics(TEST_TEMPLATE).map(d => d.messageText);
expect(diags).toContain( expect(diags).toContain(
`Identifier 'people_1' is not defined. ` + `Identifier 'people' is not defined. ` +
`The component declaration, template variable declarations, ` + `The component declaration, template variable declarations, ` +
`and element references do not contain such a member`); `and element references do not contain such a member`);
}); });
it('should report an unknown value in a key expression', () => { it('should report an unknown value in a key expression', () => {
const diags = ngLS.getSemanticDiagnostics(NG_FOR_CASES).map(d => d.messageText); mockHost.override(TEST_TEMPLATE, `<div *ngFor="let hero of heroes; trackBy: trackByFn"></div>`);
expect(diags).toContain( const diags = ngLS.getSemanticDiagnostics(TEST_TEMPLATE).map(d => d.messageText);
`Identifier 'trackBy_1' is not defined. ` + expect(diags).toContain(
`The component declaration, template variable declarations, ` + `Identifier 'trackByFn' is not defined. ` +
`and element references do not contain such a member`); `The component declaration, template variable declarations, ` +
}); `and element references do not contain such a member`);
}); });
describe('embedded templates', () => { describe('embedded templates', () => {

View File

@ -10,16 +10,12 @@ import {CommonModule} from '@angular/common';
import {NgModule} from '@angular/core'; import {NgModule} from '@angular/core';
import {FormsModule} from '@angular/forms'; import {FormsModule} from '@angular/forms';
import {AppComponent} from './app.component'; import {AppComponent} from './app.component';
import * as NgForCases from './ng-for-cases';
import * as ParsingCases from './parsing-cases'; import * as ParsingCases from './parsing-cases';
@NgModule({ @NgModule({
imports: [CommonModule, FormsModule], imports: [CommonModule, FormsModule],
declarations: [ declarations: [
AppComponent, AppComponent,
NgForCases.UnknownEven,
NgForCases.UnknownPeople,
NgForCases.UnknownTrackBy,
ParsingCases.AsyncForUsingComponent, ParsingCases.AsyncForUsingComponent,
ParsingCases.CaseIncompleteOpen, ParsingCases.CaseIncompleteOpen,
ParsingCases.CaseMissingClosing, ParsingCases.CaseMissingClosing,

View File

@ -1,43 +0,0 @@
/**
* @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 {Component} from '@angular/core';
export interface Person {
name: string;
age: number;
}
@Component({
template: `
<div *ngFor="let person of ~{start-people_1}people_1~{end-people_1}">
<span>{{person.name}}</span>
</div>`,
})
export class UnknownPeople {
}
@Component({
template: `
<div ~{start-even_1}*ngFor="let person of people; let e = even_1"~{end-even_1}>
<span>{{person.name}}</span>
</div>`,
})
export class UnknownEven {
people: Person[] = [];
}
@Component({
template: `
<div *ngFor="let person of people; trackBy ~{start-trackBy_1}trackBy_1~{end-trackBy_1}">
<span>{{person.name}}</span>
</div>`,
})
export class UnknownTrackBy {
people: Person[] = [];
}