From fb5f567498486922757e5aaddbe0825cf7018e6d Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sun, 25 Feb 2024 23:57:30 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20add=20new=20test=20for=20diff=20?= =?UTF-8?q?streaming?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/test/diff.test.ts | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/core/test/diff.test.ts b/core/test/diff.test.ts index 92a5cfc2f..ccbbfa4b6 100644 --- a/core/test/diff.test.ts +++ b/core/test/diff.test.ts @@ -1,6 +1,18 @@ import { streamDiff } from "../diff/streamDiff"; const oldCode = [ + `A +B`, + `A +B +C`, + `A +B +C +A +B +B +A`, `function mergeSortAlgorithm() { // TODO: implement }`, @@ -10,6 +22,19 @@ const oldCode = [ ]; const newCode = [ + `C +D`, + `D +E +C +F +C`, + `C +B +A +B +A +C`, `function mergeSortAlgorithm(arr: number[]): number[] { if (arr.length <= 1) { return arr; @@ -113,7 +138,11 @@ describe("streamDiff", () => { // Check that there are no red lines immediately following green (they should always be above) for (let i = 1; i < diff.length; i++) { if (diff[i].type === "old" && diff[i - 1].type === "new") { - throw new Error("Found red immediately after green line"); + throw new Error( + `Found red '${diff[i].line}' immediately after green line '${ + diff[i - 1].line + }` + ); } } });