From 06c193c5597d7ad2381033676d94219a0f520377 Mon Sep 17 00:00:00 2001 From: Alex Kanunnikov Date: Tue, 9 Jul 2024 11:15:55 +0300 Subject: [PATCH] + --- tests/transaction.test.ts | 41 +++------------------------------------ 1 file changed, 3 insertions(+), 38 deletions(-) diff --git a/tests/transaction.test.ts b/tests/transaction.test.ts index 660d1bc..4bca16a 100644 --- a/tests/transaction.test.ts +++ b/tests/transaction.test.ts @@ -130,44 +130,6 @@ describe("transaction", () => { assert.equal(app.value, 10); } }); - test("unable to mutate cell outside of transaction if its already used inside transaction", async () => { - const app = getApp(); - app.value = 10; - const transaction = new Transaction(() => { - app.value = 20; - }); - try { - app.value = 12; - } catch (error: any) { - assert.equal( - error.message, - "Unable to mutate signal used in ongoing transaction" - ); - assert.equal(app.value, 20); - } - assert.ok(transaction); - }); - test("unable to consume mutated cell in transaction if its mutated after transaction creation", async () => { - const v1 = getApp(); - const v2 = getApp(); - v1.value = 10; - v2.value = 10; - const transaction = new Transaction(() => { - v1.value = 20; - }); - v2.value = 3; - try { - transaction.execute(() => { - v2.value = 4; - }); - } catch (error: any) { - assert.equal( - error.message, - "Unable to consume signal because its mutated after transaction creation" - ); - assert.equal(v2.value, 3); - } - }); test("Changes made outside of a transaction are not visible within the transaction.", async () => { const app = getApp(10); assert.equal(app.value, 10); @@ -202,13 +164,16 @@ describe("transaction", () => { const transaction2 = new Transaction(() => { app.value = 30; }); + let isErrored = false; transaction1.commit(); assert.equal(app.value, 20); try { transaction2.commit(); } catch (error: any) { + isErrored = true; assert.equal(error.message, "Transaction conflict"); assert.equal(app.value, 20); } + assert.equal(isErrored, true); }); });