test(language-service): Move pipe tests to TEST_TEMPLATE (#36407)
This commit simplifies the completion tests for pipes by moving them to TEST_TEMPLATE. PR Close #36407
This commit is contained in:
parent
8660806ddc
commit
eb8c6c7eff
|
@ -469,21 +469,24 @@ describe('completions', () => {
|
|||
|
||||
describe('for pipes', () => {
|
||||
it('should be able to get a list of pipe values', () => {
|
||||
for (const location of ['before-pipe', 'in-pipe', 'after-pipe']) {
|
||||
const marker = mockHost.getLocationMarkerFor(PARSING_CASES, location);
|
||||
const completions = ngLS.getCompletionsAtPosition(PARSING_CASES, marker.start);
|
||||
expectContain(completions, CompletionKind.PIPE, [
|
||||
'async',
|
||||
'uppercase',
|
||||
'lowercase',
|
||||
'titlecase',
|
||||
]);
|
||||
}
|
||||
// TODO(kyliau): does not work for case {{ title | ~{cursor} }}
|
||||
// space before and after pipe ^^^
|
||||
mockHost.override(TEST_TEMPLATE, `{{ title|~{cursor} }}`);
|
||||
const marker = mockHost.getLocationMarkerFor(TEST_TEMPLATE, 'cursor');
|
||||
const completions = ngLS.getCompletionsAtPosition(TEST_TEMPLATE, marker.start);
|
||||
expectContain(completions, CompletionKind.PIPE, [
|
||||
'async',
|
||||
'lowercase',
|
||||
'slice',
|
||||
'titlecase',
|
||||
'uppercase',
|
||||
]);
|
||||
});
|
||||
|
||||
it('should be able to resolve lowercase', () => {
|
||||
const marker = mockHost.getLocationMarkerFor(EXPRESSION_CASES, 'string-pipe');
|
||||
const completions = ngLS.getCompletionsAtPosition(EXPRESSION_CASES, marker.start);
|
||||
mockHost.override(TEST_TEMPLATE, `{{ (title | lowercase).~{cursor} }}`);
|
||||
const marker = mockHost.getLocationMarkerFor(TEST_TEMPLATE, 'cursor');
|
||||
const completions = ngLS.getCompletionsAtPosition(TEST_TEMPLATE, marker.start);
|
||||
expectContain(completions, CompletionKind.METHOD, [
|
||||
'charAt',
|
||||
'replace',
|
||||
|
|
|
@ -39,10 +39,3 @@ export class PrivateReference {
|
|||
})
|
||||
export class ExpectNumericType {
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: '{{ (name | lowercase).~{string-pipe}substring }}',
|
||||
})
|
||||
export class LowercasePipe {
|
||||
name: string = 'name';
|
||||
}
|
||||
|
|
|
@ -21,7 +21,6 @@ import * as ParsingCases from './parsing-cases';
|
|||
declarations: [
|
||||
AppComponent,
|
||||
ExpressionCases.ExpectNumericType,
|
||||
ExpressionCases.LowercasePipe,
|
||||
ExpressionCases.PrivateReference,
|
||||
ExpressionCases.WrongFieldReference,
|
||||
ExpressionCases.WrongSubFieldReference,
|
||||
|
@ -38,7 +37,6 @@ import * as ParsingCases from './parsing-cases';
|
|||
ParsingCases.HintModel,
|
||||
ParsingCases.NoValueAttribute,
|
||||
ParsingCases.NumberModel,
|
||||
ParsingCases.Pipes,
|
||||
ParsingCases.References,
|
||||
ParsingCases.StringModel,
|
||||
ParsingCases.TemplateReference,
|
||||
|
@ -51,4 +49,4 @@ export class AppModule {
|
|||
|
||||
declare function bootstrap(v: any): void;
|
||||
|
||||
bootstrap(AppComponent);
|
||||
bootstrap(AppComponent);
|
||||
|
|
|
@ -31,13 +31,6 @@ export class CaseMissingClosing {
|
|||
export class CaseUnknown {
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: '<h1>{{data | ~{before-pipe}lowe~{in-pipe}rcase~{after-pipe} }}',
|
||||
})
|
||||
export class Pipes {
|
||||
data = 'Some string';
|
||||
}
|
||||
|
||||
@Component({
|
||||
template: '<h1 h~{no-value-attribute}></h1>',
|
||||
})
|
||||
|
@ -175,7 +168,7 @@ export class TemplateReference {
|
|||
myClick(event: any) {}
|
||||
birthday = new Date();
|
||||
readonlyHeroes: ReadonlyArray<Readonly<Hero>> = this.heroes;
|
||||
constNames = [{name: 'name'}] as const ;
|
||||
constNames = [{name: 'name'}] as const;
|
||||
}
|
||||
|
||||
@Component({
|
||||
|
|
|
@ -94,7 +94,7 @@ describe('TypeScriptServiceHost', () => {
|
|||
const tsLS = ts.createLanguageService(tsLSHost);
|
||||
const ngLSHost = new TypeScriptServiceHost(tsLSHost, tsLS);
|
||||
const templates = ngLSHost.getTemplates('/app/parsing-cases.ts');
|
||||
expect(templates.length).toBe(9);
|
||||
expect(templates.length).toBe(8);
|
||||
});
|
||||
|
||||
it('should be able to find external template', () => {
|
||||
|
|
Loading…
Reference in New Issue