Skip to main content
Module

x/evt/test/test78.ts

💧EventEmitter's typesafe replacement
Go to Latest
File

import { Evt } from "../lib/index.ts";import { getPromiseAssertionApi } from "../tools/testing/getPromiseAssertionApi.ts";
const { mustResolve, mustStayPending } = getPromiseAssertionApi();
(async () => {

{
const sevText = Evt.create("");
const pr1 = mustResolve({ "promise": sevText.waitFor(), "expectedData": "" });
const pr2 = mustResolve({ "promise": sevText.evtDiff.waitFor(({ newState }) => newState === "" ? [newState] : null), "expectedData": "" });
mustStayPending(sevText.evtChange.waitFor()); mustStayPending(sevText.evtChangeDiff.waitFor());

sevText.post(sevText.state);
await Promise.all([pr1, pr2]);
}
{
const sevText = Evt.create("");
const pr1 = mustResolve({ "promise": sevText.waitFor(), "expectedData": "" });
const pr2 = mustResolve({ "promise": sevText.evtDiff.waitFor(({ newState }) => newState === "" ? [newState] : null), "expectedData": "" });
mustStayPending(sevText.evtChange.waitFor()); mustStayPending(sevText.evtChangeDiff.waitFor());
sevText.state = sevText.state;
await Promise.all([pr1, pr2]);
}
console.log("PASS");
})();