Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function createHostFactory(typeOrOptions: Type | SpectatorHostOptions): SpectatorHostFactory {
return baseCreateHostFactory({
mockProvider,
...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions)
}) as SpectatorHostFactory;
}
export function createHttpFactory<s>(typeOrOptions: SpectatorHttpOptions<s> | Type<s>): SpectatorHttpFactory<s> {
return baseCreateHttpFactory({
mockProvider,
...(isType(typeOrOptions) ? { dataService: typeOrOptions } : typeOrOptions)
}) as SpectatorHttpFactory<s>;
}
</s></s></s></s></s>
export function createRoutingFactory(typeOrOptions: SpectatorRoutingOptions | Type): SpectatorRoutingFactory {
return baseCreateRoutingFactory({
mockProvider,
...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions)
}) as SpectatorRoutingFactory;
}
export function createServiceFactory<s>(typeOrOptions: SpectatorServiceOptions<s> | Type<s>): SpectatorServiceFactory<s> {
return baseCreateServiceFactory({
mockProvider,
...(isType(typeOrOptions) ? { service: typeOrOptions } : typeOrOptions)
}) as SpectatorServiceFactory<s>;
}
</s></s></s></s></s>
export function createComponentFactory(typeOrOptions: SpectatorOptions | Type): SpectatorFactory {
return baseCreateComponentFactory({
mockProvider,
...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions)
}) as SpectatorFactory;
}
export function createDirectiveFactory(
typeOrOptions: Type | SpectatorDirectiveOptions
): SpectatorDirectiveFactory {
return baseCreateDirectiveFactory({
mockProvider,
...(isType(typeOrOptions) ? { directive: typeOrOptions } : typeOrOptions)
}) as SpectatorDirectiveFactory;
}
export function createService<s>(typeOrOptions: SpectatorServiceOptions<s> | Type<s>): SpectatorService<s> {
return baseCreateService({
mockProvider,
...(isType(typeOrOptions) ? { service: typeOrOptions } : typeOrOptions)
}) as SpectatorService<s>;
}
</s></s></s></s></s>
export function createSpyObject(type: InjectableType, template?: Partial>): SpyObject {
const mock: any = { ...template } || {};
installProtoMethods(mock, type.prototype, () => {
const jestFn = jest.fn();
const newSpy: CompatibleSpy = jestFn as any;
newSpy.andCallFake = (fn: Function) => {
jestFn.mockImplementation(fn as (...args: any[]) => any);
return newSpy;
};
newSpy.andReturn = (val: any) => {
jestFn.mockReturnValue(val);
};
newSpy.reset = () => {
jestFn.mockReset();
};
export function createSpyObject(type: InjectableType, template?: Partial>): SpyObject {
const mock: any = template || {};
installProtoMethods(mock, type.prototype, () => {
const jestFn = jest.fn();
const newSpy: CompatibleSpy = jestFn as any;
newSpy.andCallFake = (fn: Function) => {
jestFn.mockImplementation(fn as (...args: any[]) => any);
return newSpy;
};
newSpy.andReturn = (val: any) => {
jestFn.mockReturnValue(val);
};
newSpy.reset = () => {
jestFn.mockReset();
};
export function createComponentFactory(typeOrOptions: SpectatorOptions | Type): SpectatorFactory {
return baseCreateComponentFactory({
mockProvider,
...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions)
}) as SpectatorFactory;
}