How to use @ngneat/spectator - 10 common examples

To help you get started, we’ve selected a few @ngneat/spectator examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github ngneat / spectator / projects / spectator / jest / src / lib / spectator-host.ts View on Github external
export function createHostFactory(typeOrOptions: Type | SpectatorHostOptions): SpectatorHostFactory {
  return baseCreateHostFactory({
    mockProvider,
    ...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions)
  }) as SpectatorHostFactory;
}
github ngneat / spectator / projects / spectator / jest / src / lib / spectator-http.ts View on Github external
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>
github ngneat / spectator / projects / spectator / jest / src / lib / spectator-routing.ts View on Github external
export function createRoutingFactory(typeOrOptions: SpectatorRoutingOptions | Type): SpectatorRoutingFactory {
  return baseCreateRoutingFactory({
    mockProvider,
    ...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions)
  }) as SpectatorRoutingFactory;
}
github ngneat / spectator / projects / spectator / jest / src / lib / spectator-service.ts View on Github external
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>
github ngneat / spectator / projects / spectator / jest / src / lib / spectator.ts View on Github external
export function createComponentFactory(typeOrOptions: SpectatorOptions | Type): SpectatorFactory {
  return baseCreateComponentFactory({
    mockProvider,
    ...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions)
  }) as SpectatorFactory;
}
github ngneat / spectator / projects / spectator / jest / src / lib / spectator-directive.ts View on Github external
export function createDirectiveFactory(
  typeOrOptions: Type | SpectatorDirectiveOptions
): SpectatorDirectiveFactory {
  return baseCreateDirectiveFactory({
    mockProvider,
    ...(isType(typeOrOptions) ? { directive: typeOrOptions } : typeOrOptions)
  }) as SpectatorDirectiveFactory;
}
github ngneat / spectator / projects / spectator / jest / src / lib / spectator-service.ts View on Github external
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>
github ngneat / spectator / projects / spectator / jest / src / lib / mock.ts View on Github external
export function createSpyObject(type: InjectableType, template?: Partial&gt;): SpyObject {
  const mock: any = { ...template } || {};

  installProtoMethods(mock, type.prototype, () =&gt; {
    const jestFn = jest.fn();
    const newSpy: CompatibleSpy = jestFn as any;

    newSpy.andCallFake = (fn: Function) =&gt; {
      jestFn.mockImplementation(fn as (...args: any[]) =&gt; any);

      return newSpy;
    };

    newSpy.andReturn = (val: any) =&gt; {
      jestFn.mockReturnValue(val);
    };

    newSpy.reset = () =&gt; {
      jestFn.mockReset();
    };
github ngneat / spectator / projects / spectator / jest / src / lib / mock.ts View on Github external
export function createSpyObject(type: InjectableType, template?: Partial&gt;): SpyObject {
  const mock: any = template || {};

  installProtoMethods(mock, type.prototype, () =&gt; {
    const jestFn = jest.fn();
    const newSpy: CompatibleSpy = jestFn as any;

    newSpy.andCallFake = (fn: Function) =&gt; {
      jestFn.mockImplementation(fn as (...args: any[]) =&gt; any);

      return newSpy;
    };

    newSpy.andReturn = (val: any) =&gt; {
      jestFn.mockReturnValue(val);
    };

    newSpy.reset = () =&gt; {
      jestFn.mockReset();
    };
github ngneat / spectator / projects / spectator / jest / src / lib / spectator.ts View on Github external
export function createComponentFactory(typeOrOptions: SpectatorOptions | Type): SpectatorFactory {
  return baseCreateComponentFactory({
    mockProvider,
    ...(isType(typeOrOptions) ? { component: typeOrOptions } : typeOrOptions)
  }) as SpectatorFactory;
}