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:
parent
868b8743d8
commit
963ec65bbc
1 changed files with 56 additions and 5 deletions
|
|
@ -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);
|
||||
});
|
||||
|
|
|
|||
Loading…
Reference in a new issue