paperless-ngx/src-ui/test-config.helper.ts

25 lines
606 B
TypeScript
Raw Normal View History

import { TestBed } from '@angular/core/testing'
2022-03-22 14:33:00 +01:00
type CompilerOptions = Partial<{
providers: any[]
useJit: boolean
preserveWhitespaces: boolean
}>
export type ConfigureFn = (testBed: typeof TestBed) => void
2022-03-22 14:33:00 +01:00
export const configureTests = (
configure: ConfigureFn,
compilerOptions: CompilerOptions = {}
) => {
2022-03-22 14:33:00 +01:00
const compilerConfig: CompilerOptions = {
preserveWhitespaces: false,
...compilerOptions,
}
2022-03-22 14:33:00 +01:00
const configuredTestBed = TestBed.configureCompiler(compilerConfig)
2022-03-22 14:33:00 +01:00
configure(configuredTestBed)
2022-03-22 14:33:00 +01:00
return configuredTestBed.compileComponents().then(() => configuredTestBed)
}