From 7f28845f5857184de8259f47b80daa85afc83de1 Mon Sep 17 00:00:00 2001 From: Keen Yee Liau Date: Mon, 6 Apr 2020 20:04:56 -0700 Subject: [PATCH] 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 --- .../language-service/test/diagnostics_spec.ts | 30 ++++++------- .../language-service/test/project/app/main.ts | 4 -- .../test/project/app/ng-for-cases.ts | 43 ------------------- 3 files changed, 15 insertions(+), 62 deletions(-) delete mode 100644 packages/language-service/test/project/app/ng-for-cases.ts diff --git a/packages/language-service/test/diagnostics_spec.ts b/packages/language-service/test/diagnostics_spec.ts index 1bea06f6cd..d8e0218954 100644 --- a/packages/language-service/test/diagnostics_spec.ts +++ b/packages/language-service/test/diagnostics_spec.ts @@ -274,22 +274,22 @@ describe('diagnostics', () => { expect(diags).toContain('Expected a number type'); }); - describe('in ng-for-cases.ts', () => { - it('should report an unknown field', () => { - const diags = ngLS.getSemanticDiagnostics(NG_FOR_CASES).map(d => d.messageText); - expect(diags).toContain( - `Identifier 'people_1' is not defined. ` + - `The component declaration, template variable declarations, ` + - `and element references do not contain such a member`); - }); + it('should report an unknown field', () => { + mockHost.override(TEST_TEMPLATE, `
`); + const diags = ngLS.getSemanticDiagnostics(TEST_TEMPLATE).map(d => d.messageText); + expect(diags).toContain( + `Identifier 'people' is not defined. ` + + `The component declaration, template variable declarations, ` + + `and element references do not contain such a member`); + }); - it('should report an unknown value in a key expression', () => { - const diags = ngLS.getSemanticDiagnostics(NG_FOR_CASES).map(d => d.messageText); - expect(diags).toContain( - `Identifier 'trackBy_1' is not defined. ` + - `The component declaration, template variable declarations, ` + - `and element references do not contain such a member`); - }); + it('should report an unknown value in a key expression', () => { + mockHost.override(TEST_TEMPLATE, `
`); + const diags = ngLS.getSemanticDiagnostics(TEST_TEMPLATE).map(d => d.messageText); + expect(diags).toContain( + `Identifier 'trackByFn' is not defined. ` + + `The component declaration, template variable declarations, ` + + `and element references do not contain such a member`); }); describe('embedded templates', () => { diff --git a/packages/language-service/test/project/app/main.ts b/packages/language-service/test/project/app/main.ts index 8a9a97f805..85d2b7a440 100644 --- a/packages/language-service/test/project/app/main.ts +++ b/packages/language-service/test/project/app/main.ts @@ -10,16 +10,12 @@ import {CommonModule} from '@angular/common'; import {NgModule} from '@angular/core'; import {FormsModule} from '@angular/forms'; import {AppComponent} from './app.component'; -import * as NgForCases from './ng-for-cases'; import * as ParsingCases from './parsing-cases'; @NgModule({ imports: [CommonModule, FormsModule], declarations: [ AppComponent, - NgForCases.UnknownEven, - NgForCases.UnknownPeople, - NgForCases.UnknownTrackBy, ParsingCases.AsyncForUsingComponent, ParsingCases.CaseIncompleteOpen, ParsingCases.CaseMissingClosing, diff --git a/packages/language-service/test/project/app/ng-for-cases.ts b/packages/language-service/test/project/app/ng-for-cases.ts deleted file mode 100644 index 9b46ed5dc3..0000000000 --- a/packages/language-service/test/project/app/ng-for-cases.ts +++ /dev/null @@ -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: ` -
- {{person.name}} -
`, -}) -export class UnknownPeople { -} - -@Component({ - template: ` -
- {{person.name}} -
`, -}) -export class UnknownEven { - people: Person[] = []; -} - -@Component({ - template: ` -
- {{person.name}} -
`, -}) -export class UnknownTrackBy { - people: Person[] = []; -}