MCPcopy Create free account
hub / github.com/angular/angular / setupInlineTemplate

Function setupInlineTemplate

packages/language-service/test/completions_spec.ts:2442–2482  ·  view source on GitHub ↗
(
  template: string,
  classContents: string,
  otherDeclarations: {[name: string]: string} = {},
  componentMetadata = '',
  compilerOptions?: TestableOptions,
)

Source from the content-addressed store, hash-verified

2440}
2441
2442function setupInlineTemplate(
2443 template: string,
2444 classContents: string,
2445 otherDeclarations: {[name: string]: string} = {},
2446 componentMetadata = '',
2447 compilerOptions?: TestableOptions,
2448): {
2449 appFile: OpenBuffer;
2450} {
2451 const decls = ['AppCmp', ...Object.keys(otherDeclarations)];
2452
2453 const otherDirectiveClassDecls = Object.values(otherDeclarations).join('\n\n');
2454
2455 const env = LanguageServiceTestEnv.setup();
2456 const project = env.addProject(
2457 'test',
2458 {
2459 'test.ts': `
2460 import {Component, Directive, NgModule, Pipe, TemplateRef} from '@angular/core';
2461
2462 @Component({
2463 template: '${template}',
2464 selector: 'app-cmp',
2465 ${componentMetadata}
2466 })
2467 export class AppCmp {
2468 ${classContents}
2469 }
2470
2471 ${otherDirectiveClassDecls}
2472
2473 @NgModule({
2474 declarations: [${decls.join(', ')}],
2475 })
2476 export class AppModule {}
2477 `,
2478 },
2479 compilerOptions,
2480 );
2481 return {appFile: project.openFile('test.ts')};
2482}

Callers 1

Calls 6

valuesMethod · 0.80
addProjectMethod · 0.80
keysMethod · 0.65
joinMethod · 0.65
setupMethod · 0.45
openFileMethod · 0.45

Tested by

no test coverage detected