test: tighten json file lock coverage

This commit is contained in:
Peter Steinberger 2026-03-14 00:27:40 +00:00
parent 56798bd811
commit 3920c444cb
1 changed files with 20 additions and 0 deletions

View File

@ -65,4 +65,24 @@ describe("json file helpers", () => {
await expect(second).resolves.toBe("ok");
expect(events).toEqual(["first:start", "first:end", "second:start", "second:end"]);
});
it("releases the async lock after synchronous throws", async () => {
const withLock = createAsyncLock();
const events: string[] = [];
const first = withLock(async () => {
events.push("first:start");
throw new Error("sync boom");
});
const second = withLock(async () => {
events.push("second:start");
events.push("second:end");
return "ok";
});
await expect(first).rejects.toThrow("sync boom");
await expect(second).resolves.toBe("ok");
expect(events).toEqual(["first:start", "second:start", "second:end"]);
});
});