From 851356d0029f8a81487e633517947bd24bf5fe41 Mon Sep 17 00:00:00 2001 From: Abdulrahim Al Methiab Date: Thu, 26 Oct 2023 17:29:11 +0200 Subject: [PATCH] adjust tests --- bindings/wasm/tests/storage.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/bindings/wasm/tests/storage.ts b/bindings/wasm/tests/storage.ts index 60b3d6a3a7..cad4e85fe9 100644 --- a/bindings/wasm/tests/storage.ts +++ b/bindings/wasm/tests/storage.ts @@ -473,7 +473,7 @@ describe("#OptionParsing", function() { }); }); -describe("#documents throw error on concurrent access", async function() { +describe("#Documents throw error on concurrent synchronous access", async function() { const wait: any = (ms: any) => new Promise(r => setTimeout(r, ms)); class MyJwkStore extends JwkMemStore { @@ -501,11 +501,14 @@ describe("#documents throw error on concurrent access", async function() { return document.id(); }); + let resolvedToError = false; try { await Promise.all([insertPromise, idPromise]); } catch (e: any) { + resolvedToError = true; assert.equal(e.name, "TryLockError"); } + assert.ok(resolvedToError, "Promise.all did not throw an error"); }); it("IotaDocument", async () => { @@ -522,11 +525,13 @@ describe("#documents throw error on concurrent access", async function() { const idPromise = wait(10).then((_value: any) => { return document.id(); }); - + let resolvedToError = false; try { await Promise.all([insertPromise, idPromise]); } catch (e: any) { + resolvedToError = true; assert.equal(e.name, "TryLockError"); } + assert.ok(resolvedToError, "Promise.all did not throw an error"); }); });