Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 | 1x 8x 8x 8x 8x 8x | import { CUSTOM_ELEMENTS_SCHEMA } from '@angular/core';
import type { TestModuleMetadata } from '@angular/core/testing';
import { AppMocksCoreModule } from '../testing-unit.module';
/**
* New TestBed metadata getter type.
*/
export type TNewTestBedMetadata = (metadata?: TestModuleMetadata) => TestModuleMetadata;
/**
* New TestBed metadata getter.
* Should be used to provide additional metadata to default test bed config.
* Provide a result as a parameter to getTestBedConfig method.
*/
export const newTestBedMetadata: TNewTestBedMetadata = (metadata?: TestModuleMetadata) => {
const imports = [...(metadata?.imports ?? [])];
const declarations = [...(metadata?.declarations ?? [])];
const providers = [...(metadata?.providers ?? [])];
const schemas = [...(metadata?.schemas ?? [])];
const teardown = { ...(metadata?.teardown ?? { destroyAfterEach: true }) };
return {
imports,
declarations,
providers,
schemas,
teardown,
};
};
/**
* TestBed config getter type.
*/
export type TTestBedConfigGetter = (metadata?: TestModuleMetadata) => TestModuleMetadata;
/**
* TestBed configuration getter.
* @param metadata additional test bed metadata
*/
export const getTestBedConfig: TTestBedConfigGetter = (metadata: TestModuleMetadata = newTestBedMetadata()) => ({
declarations: [...(metadata.declarations ?? [])],
imports: [AppMocksCoreModule.forRoot(), ...(metadata.imports ?? [])],
providers: [...(metadata.providers ?? [])],
schemas: [CUSTOM_ELEMENTS_SCHEMA, ...(metadata.schemas ?? [])],
teardown: { ...(metadata.teardown ?? { destroyAfterEach: true }) },
});
|