test: require matrix async callbacks · openclaw/openclaw@d5ccdab
steipete
·
2026-05-09
·
via Recent Commits to openclaw:main
File tree
extensions/matrix/src/matrix
| Original file line number | Diff line number | Diff line change |
|---|
@@ -305,12 +305,15 @@ describe("promoteMatrixDirectRoomCandidate", () => {
|
305 | 305 | |
306 | 306 | it("serializes concurrent m.direct writes so distinct mappings are not lost", async () => { |
307 | 307 | let directContent: Record<string, string[]> = {}; |
308 | | -let releaseFirstWrite!: () => void; |
| 308 | +let releaseFirstWrite: (() => void) | undefined; |
309 | 309 | const firstWriteStarted = new Promise<void>((resolve) => { |
310 | 310 | releaseFirstWrite = () => { |
311 | 311 | resolve(); |
312 | 312 | }; |
313 | 313 | }); |
| 314 | +if (!releaseFirstWrite) { |
| 315 | +throw new Error("Expected first m.direct write release callback to be initialized"); |
| 316 | +} |
314 | 317 | let writeCount = 0; |
315 | 318 | const setAccountData = vi.fn(async (_eventType: string, content: Record<string, string[]>) => { |
316 | 319 | writeCount += 1; |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -90,10 +90,13 @@ beforeEach(() => {
|
90 | 90 | }); |
91 | 91 | |
92 | 92 | function deferred<T>() { |
93 | | -let resolve!: (value: T | PromiseLike<T>) => void; |
| 93 | +let resolve: ((value: T | PromiseLike<T>) => void) | undefined; |
94 | 94 | const promise = new Promise<T>((res) => { |
95 | 95 | resolve = res; |
96 | 96 | }); |
| 97 | +if (!resolve) { |
| 98 | +throw new Error("Expected deferred resolver to be initialized"); |
| 99 | +} |
97 | 100 | return { promise, resolve }; |
98 | 101 | } |
99 | 102 | |
|
| Original file line number | Diff line number | Diff line change |
|---|
@@ -548,10 +548,13 @@ describe("MatrixVerificationManager", () => {
|
548 | 548 | }); |
549 | 549 | |
550 | 550 | it("confirmVerificationSas awaits the verifier's verify promise before resolving", async () => { |
551 | | -let resolveVerify!: () => void; |
| 551 | +let resolveVerify: (() => void) | undefined; |
552 | 552 | const verifyPromise = new Promise<void>((res) => { |
553 | 553 | resolveVerify = res; |
554 | 554 | }); |
| 555 | +if (!resolveVerify) { |
| 556 | +throw new Error("Expected verification resolver to be initialized"); |
| 557 | +} |
555 | 558 | const verifyImpl = vi.fn(() => verifyPromise); |
556 | 559 | const { confirm, verifier } = createSasVerifierFixture({ |
557 | 560 | decimal: [111, 222, 333], |
|
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。