(
template: string,
classContents: string,
otherDeclarations: {[name: string]: string} = {},
functionDeclarations: string = '',
componentMetadata: string = '',
standaloneFiles: ProjectFiles = {},
tsCompilerOptions = {},
projectName: string = 'test',
)
| 2379 | } |
| 2380 | |
| 2381 | function setup( |
| 2382 | template: string, |
| 2383 | classContents: string, |
| 2384 | otherDeclarations: {[name: string]: string} = {}, |
| 2385 | functionDeclarations: string = '', |
| 2386 | componentMetadata: string = '', |
| 2387 | standaloneFiles: ProjectFiles = {}, |
| 2388 | tsCompilerOptions = {}, |
| 2389 | projectName: string = 'test', |
| 2390 | ): { |
| 2391 | templateFile: OpenBuffer; |
| 2392 | project: Project; |
| 2393 | } { |
| 2394 | const decls = ['AppCmp', ...Object.keys(otherDeclarations)]; |
| 2395 | |
| 2396 | const otherDirectiveClassDecls = Object.values(otherDeclarations).join('\n\n'); |
| 2397 | |
| 2398 | const env = getSharedEnv(); |
| 2399 | const project = env.addProject( |
| 2400 | projectName, |
| 2401 | { |
| 2402 | 'test.ts': ` |
| 2403 | import {Component, |
| 2404 | input, |
| 2405 | output, |
| 2406 | model, |
| 2407 | Directive, |
| 2408 | NgModule, |
| 2409 | Pipe, |
| 2410 | TemplateRef, |
| 2411 | } from '@angular/core'; |
| 2412 | import {outputFromObservable} from '@angular/core/rxjs-interop'; |
| 2413 | import {Subject} from 'rxjs'; |
| 2414 | |
| 2415 | ${functionDeclarations} |
| 2416 | |
| 2417 | @Component({ |
| 2418 | templateUrl: './test.html', |
| 2419 | selector: 'app-cmp', |
| 2420 | ${componentMetadata} |
| 2421 | }) |
| 2422 | export class AppCmp { |
| 2423 | ${classContents} |
| 2424 | } |
| 2425 | |
| 2426 | ${otherDirectiveClassDecls} |
| 2427 | |
| 2428 | @NgModule({ |
| 2429 | declarations: [${decls.join(', ')}], |
| 2430 | }) |
| 2431 | export class AppModule {} |
| 2432 | `, |
| 2433 | 'test.html': template, |
| 2434 | ...standaloneFiles, |
| 2435 | }, |
| 2436 | undefined, |
| 2437 | tsCompilerOptions, |
| 2438 | ); |
no test coverage detected