From aef91c7b7a8ed37ffb22c7e3b3009708891b63e1 Mon Sep 17 00:00:00 2001 From: jamiewinder Date: Sat, 15 Apr 2017 21:56:38 +0100 Subject: [PATCH] expand on the computed equals invocation test --- test/typescript/typescript-tests.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/test/typescript/typescript-tests.ts b/test/typescript/typescript-tests.ts index 877cb2273..2468aa5b1 100644 --- a/test/typescript/typescript-tests.ts +++ b/test/typescript/typescript-tests.ts @@ -1161,7 +1161,7 @@ test("@computed.equals (TS)", t => { }); -test("computed equals comparer", t => { +test("computed equals function only invoked when necessary", t => { const comparisons: Array<{ from: string, to: string }> = []; const comparer = (from: string, to: string) => { comparisons.push({ from, to }); @@ -1189,15 +1189,20 @@ test("computed equals comparer", t => { left.set(null); t.deepEqual(comparisons, [{ from: "ab", to: "cb" }]); + // Transition *between* CaughtException-s in the computed won't cause a comparison + right.set(null); + t.deepEqual(comparisons, [{ from: "ab", to: "cb" }]); + // Transition *from* CaughtException in the computed won't cause a comparison left.set("D"); + right.set("E"); t.deepEqual(comparisons, [{ from: "ab", to: "cb" }]); // Another value change will cause a comparison - right.set("E"); - t.deepEqual(comparisons, [{ from: "ab", to: "cb" }, { from: "db", to: "de" }]); + right.set("F"); + t.deepEqual(comparisons, [{ from: "ab", to: "cb" }, { from: "de", to: "df" }]); - t.deepEqual(values, ["ab", "cb", "db", "de"]); + t.deepEqual(values, ["ab", "cb", "de", "df"]); disposeAutorun();