UNPKG

promises-arrow

Version:

`promises-arrow` is a library of (1) higher order functions, such as `map()` and `filter()`where the function returns a Promisel (2) Functions that wait, returning a Promise; (3) Functions that manage retrying an operation N times until it succeeds; (4,5)

35 lines (30 loc) 989 B
import {assertThat} from "mismatched"; import {promises} from "./promises"; describe('WaitPromise:', () => { let sideEffects: Array<number> = []; beforeEach(() => { sideEffects = []; }); it("waitForPromise()", () => { return promises .waitForPromise(1, 1) .then(value => assertThat(value).is(1)); }); describe("waitForTimeoutOrPromise():", () => { it("Promise resolves in time", () => { return promises .waitForTimeoutOrPromise(1, () => Promise.resolve(44)) .then(value => assertThat(value).is(44)); }); it("Promise does not resolves in time", () => { return promises .waitForTimeoutOrPromise(1, () => new Promise(() => 1)) .then( () => fail('unassertThated'), () => undefined); }); }); }); function fail(msg: string) { assertThat(msg).is(undefined); }