(
template: string,
classContents: string,
otherDeclarations: {[name: string]: string} = {},
componentMetadata = '',
compilerOptions?: TestableOptions,
)
| 2440 | } |
| 2441 | |
| 2442 | function 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 | } |
no test coverage detected