From 09ef95294806b42958248773ffbcf57468580100 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 30 Dec 2023 17:43:22 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=A7=AA=20add=20new=20test=20for=20diff?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/test/diff.test.ts | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/core/test/diff.test.ts b/core/test/diff.test.ts index b0ffa2205..1a167acf7 100644 --- a/core/test/diff.test.ts +++ b/core/test/diff.test.ts @@ -106,8 +106,16 @@ describe("streamDiff", () => { const numOld = diff.filter((dl) => dl.type === "old").length; const numNew = diff.filter((dl) => dl.type === "new").length; + // Check that every line is represented expect(oldLines.length).toEqual(numOld + numSame); expect(newLines.length).toEqual(numNew + numSame); + + // 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"); + } + } }); } });