UNPKG

ngx-testing-tools

Version:
65 lines (64 loc) 2.85 kB
import { ProviderToken, Type } from '@angular/core'; import { TestBedStatic } from '@angular/core/testing'; import { EnhancedJasmineCallback } from '../../jasmine/models/enhanced-jasmine-callback.model'; import { JasmineCallback } from '../../jasmine/models/jasmine-callback.model'; import { NonEmptyString, PrettyMerge } from '../../shared.models'; import { BaseTools } from '../../tools/base/models/base-tools.model'; import { DeferredTools } from '../../tools/models/deferred-tools.model'; import { InjectionStore } from '../../tools/store/models/injected-store.model'; import { AnyProvider, Importation } from '../models/metadata-type.models'; import { BaseTestBedOptions } from './models/base-test-bed-options.model'; export declare abstract class BaseTestBedFactory<DescribedType, Store extends InjectionStore = InjectionStore, Tools extends BaseTools = BaseTools> { protected described: Type<DescribedType>; protected constructor(described: Type<DescribedType>, options: BaseTestBedOptions); protected testBed: TestBedStatic; private _instance; protected get instance(): DescribedType; protected abstract deferredTools: DeferredTools<Tools>; protected injectedMap: Map<string, ProviderToken<any>>; protected imports: Set<Importation>; protected providers: Set<AnyProvider>; protected injectDescribed(): void; /** * Imports one module or one standalone component / directive / pipe into the custom test bed. */ import(importation: Importation): this; /** * Imports many modules or many standalone components / directives / pipes into the custom test bed. */ import(imports: Importation[]): this; /** * Adds one provider into the custom test bed. */ provide(provider: AnyProvider): this; /** * Adds many providers into the custom test bed. */ provide(providers: AnyProvider[]): this; /** * Injects an instance by token into the custom test bed. * * Retrieve it into the tools `injected` by autocompletion. * @param name the key to access the instance. * @param token the provider token. */ inject<key extends string, T>(name: NonEmptyString<key>, token: ProviderToken<T>): BaseTestBedFactory<DescribedType, InjectionStore<PrettyMerge<Store['injected'] & { [k in key]: T; }>>>; _compileEach(): void; /** * Manually compiles the custom test bed to make enhanced tools available. * * To be used when `autoCompile = false`. * * **To be called inside jasmine `beforeEach` callback.** */ compile(): Promise<void>; /** * Sets up extra stuffs using the enhanced tools. * * **Works only for `beforeEach` and `afterEach`**. */ setup(action: EnhancedJasmineCallback<Tools>): JasmineCallback; _shouldCreate(): void; }