1.0.1 • Published 5 years ago

fp-future v1.0.1

Weekly downloads
505
License
MIT
Repository
github
Last release
5 years ago

A Future is a placeholder object for a value that may not yet exist

Installation

npm install fp-future

FP Future library

It is useful for blackbox testing without weird injections and other things.

it("executes the callback", async () => {
  const somethingToBeResolved = future();

  entity.onClick(event => {
    somethingToBeResolved.resolve(event);
  });

  const nonce = Math.random();

  setTimeout(() => somethingToBeResolved.reject(new Error("timeout")), 1000);

  entityEngine.triggerClick(nonce);

  const receivedNonce = await somethingToBeResolved;

  expect(receivedNonce).toEq(nonce);
});