Add anonymous session, re-work thunk utilities

This commit is contained in:
Jon Staab
2025-08-19 13:24:15 -07:00
parent d0d13433c3
commit 00c0497892
4 changed files with 123 additions and 91 deletions
+5 -5
View File
@@ -12,7 +12,7 @@ import {
prepEvent,
publishThunk,
thunkQueue,
walkThunks,
flattenThunks,
} from "../src/thunk"
const secret = makeSecret()
@@ -46,19 +46,19 @@ describe("thunk", () => {
const thunk2 = new Thunk(mockRequest)
const merged = new MergedThunk([thunk1, thunk2])
merged.controller.abort()
abortThunk(merged)
expect(thunk1.controller.signal.aborted).toBe(true)
expect(thunk2.controller.signal.aborted).toBe(true)
})
})
describe("walkThunks", () => {
describe("flattenThunks", () => {
it("should iterate through nested thunks", () => {
const thunk1 = new Thunk(mockRequest)
const thunk2 = new Thunk(mockRequest)
const merged = new MergedThunk([thunk1, thunk2])
const thunks = Array.from(walkThunks([merged, thunk1]))
const thunks = Array.from(flattenThunks([merged, thunk1]))
expect(thunks).toHaveLength(3)
})
@@ -78,7 +78,7 @@ describe("thunk", () => {
const removeEventSpy = vi.spyOn(repository, "removeEvent")
const thunk = publishThunk(mockRequest)
thunk.controller.abort()
abortThunk(thunk)
expect(removeEventSpy).toHaveBeenCalledWith(thunk.event.id)
})