Release Healer Man 0.1.9
This commit is contained in:
1 parent
c245a199b6
commit
d060296ade
74 files changed
+5901
-334
No files matched your search
@@ -0,0 +1,39 @@
|
||||
import { afterEach, describe, expect, it, vi } from "vitest";
|
||||
import { combatNow, installCombatClock } from "./combatClock";
|
||||
|
||||
describe("combat clock", () => {
|
||||
afterEach(() => vi.useRealTimers());
|
||||
|
||||
it("installs a deterministic clock and restores wall time", () => {
|
||||
vi.useFakeTimers();
|
||||
vi.setSystemTime(42_000);
|
||||
const restore = installCombatClock(() => 1_234);
|
||||
|
||||
try {
|
||||
expect(combatNow()).toBe(1_234);
|
||||
} finally {
|
||||
restore();
|
||||
}
|
||||
|
||||
expect(combatNow()).toBe(42_000);
|
||||
});
|
||||
|
||||
it("restores nested clock installations in last-in-first-out order", () => {
|
||||
const restoreOuter = installCombatClock(() => 100);
|
||||
|
||||
try {
|
||||
expect(combatNow()).toBe(100);
|
||||
const restoreInner = installCombatClock(() => 200);
|
||||
|
||||
try {
|
||||
expect(combatNow()).toBe(200);
|
||||
} finally {
|
||||
restoreInner();
|
||||
}
|
||||
|
||||
expect(combatNow()).toBe(100);
|
||||
} finally {
|
||||
restoreOuter();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user