Skip to content

Instantly share code, notes, and snippets.

@AlejoDev95
Created May 27, 2023 12:55
Show Gist options
  • Save AlejoDev95/e0da185edb9f3bc6e8ae9952d335c530 to your computer and use it in GitHub Desktop.
Save AlejoDev95/e0da185edb9f3bc6e8ae9952d335c530 to your computer and use it in GitHub Desktop.
Grupo de funciones que nos van a permitir trabajar con procesos asincronos en nuestras pruebas unitarias
import { defer, of } from 'rxjs';
export function asyncData<T>(data: T) {
return defer(() => Promise.resolve(data));
}
export function asyncError(error: unknown) {
return defer(() => Promise.reject(error));
}
export function mockObservable<T>(data: T) {
return of(data);
}
export function mockPromise<T>(data: T) {
return Promise.resolve(data);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment