/
test61.ts
35 lines (26 loc) 路 952 Bytes
/
test61.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Evt } from "../lib/index.ts";
import { getHandlerPr } from "./getHandlerPr.ts";
import { getPromiseAssertionApi } from "../tools/testing/getPromiseAssertionApi.ts";
import { assert } from "https://deno.land/x/tsafe@v1.5.2/assert.ts";
const { mustResolve, mustReject } = getPromiseAssertionApi();
const evtText = new Evt<string>();
evtText.attachOnce(Evt.getCtx(evtText), () => { });
mustResolve({
"promise":
getHandlerPr(
evtText.evtDetach,
() => evtText.evtDetach
.attachOnce(handler => assert(Evt.getCtx(evtText) === handler.ctx))
)
});
evtText.post("ok");
const pr = mustReject({ "promise": evtText.waitFor(0), "delay": 150 });
mustResolve({
"promise":
getHandlerPr(
evtText.evtDetach,
() => evtText.evtDetach
.attach(handler => assert(handler.timeout === 0))),
"delay": 150
});
pr.then(() => console.log("PASS"));