Watch
0
0
Fork
You've already forked hyperhive
0

swarm-ui: a toast waits while the pointer is on it

A toast left after four seconds (eight for an error) whether it had been read or
not. The countdown stops while the pointer rests on it and runs on for at least
1.5 seconds after the pointer leaves.
This commit is contained in:
iris 2026-11-28 02:49:25 +01:00 • committed by mara
commit 963ec65bbc

View file

@ -6,7 +6,9 @@ import {
currentToasts,
dismissToast,
showToast,
resumeDelay,
subscribeToasts,
timeLeft,
toastDuration,
} from "../src/ui/toast/toasts.ts";
@ -44,3 +46,15 @@ test("dismissing removes one toast and tells the subscribers once", () => {
dismissToast(a);
assert.equal(calls, 1);
});
test("a toast's time left shrinks by how long it was shown, to zero", () => {
assert.equal(timeLeft(4000, 1000), 3000);
assert.equal(timeLeft(4000, 4000), 0);
assert.equal(timeLeft(4000, 9000), 0);
});
test("a toast the pointer leaves keeps a moment, or its time left if longer", () => {
assert.equal(resumeDelay(200), 1500);
assert.equal(resumeDelay(0), 1500);
assert.equal(resumeDelay(3000), 3000);
});