Some checks failed
CLA Assistant / CLAssistant (pull_request_target) Has been cancelled
Check PR title / lint (pull_request_target) Has been cancelled
Build pull request / Build pull request (pull_request) Has been cancelled
NPM Lockfile Changes / lockfile_changes (pull_request) Has been cancelled
Pose portrait beside the bubble on wide screens and floating inside it on phones with shape-outside; asymmetric bubble corner; own messages right-aligned in the accent colour; first-appearance pop and rise, staggered, off under prefers-reduced-motion; Nunito in the GameCult theme; package name and README move to Ratatoskr, Cinny credit and AGPL notice kept. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
19 lines
792 B
TypeScript
19 lines
792 B
TypeScript
import { describe, expect, it } from 'vitest';
|
|
import { claimEntrance } from './entrance';
|
|
|
|
describe('claimEntrance', () => {
|
|
it('animates a message once, never on a remount', () => {
|
|
expect(claimEntrance('$once', 1_000_000)).toBe(0);
|
|
expect(claimEntrance('$once', 1_000_500)).toBeUndefined();
|
|
});
|
|
it('staggers messages that mount together, capped so a long backlog still lands fast', () => {
|
|
const t = 2_000_000;
|
|
const delays = ['$a', '$b', '$c', '$d', '$e', '$f'].map((id) => claimEntrance(id, t));
|
|
expect(delays.slice(0, 3)).toEqual([0, 300, 600]);
|
|
expect(Math.max(...(delays as number[]))).toBe(900);
|
|
});
|
|
it('lets a lone later message in at once', () => {
|
|
claimEntrance('$x', 3_000_000);
|
|
expect(claimEntrance('$y', 3_010_000)).toBe(0);
|
|
});
|
|
});
|