Skip to content

Commit

Permalink
+
Browse files Browse the repository at this point in the history
  • Loading branch information
lifeart committed Jul 9, 2024
1 parent 9a65878 commit 06c193c
Showing 1 changed file with 3 additions and 38 deletions.
41 changes: 3 additions & 38 deletions tests/transaction.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
});
});

0 comments on commit 06c193c

Please sign in to comment.