From 4a621d8fe55649510f005a98a77e77bb6fd50625 Mon Sep 17 00:00:00 2001 From: Cleve Stuart Date: Fri, 13 Dec 2024 11:01:55 -0500 Subject: [PATCH] Test debug --- test/lib/formatting/colorize.mjs | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/test/lib/formatting/colorize.mjs b/test/lib/formatting/colorize.mjs index 86345378..be1cc3ed 100644 --- a/test/lib/formatting/colorize.mjs +++ b/test/lib/formatting/colorize.mjs @@ -6,12 +6,6 @@ import { setupRealContainer } from "../../../src/config/setup-container.mjs"; import { colorize, Format } from "../../../src/lib/formatting/colorize.mjs"; describe("colorize", () => { - beforeEach(async () => { - // hack to get the codeToAnsi hooked up. - const container = await setupRealContainer(); - await run("--version", container); - }); - [ { format: Format.LOG, input: "Taco 8443 'Bell'", expected: "succeed" }, { format: Format.LOG, input: { hi: "Taco 8443 'Bell'" }, expected: "fail" }, @@ -25,10 +19,18 @@ describe("colorize", () => { }, { format: Format.JSON, input: { string: "23" }, expected: "succeed" }, ].forEach(({ format, input, expected }) => { - it(`should ${expected} for ${JSON.stringify(input)} in format ${format}`, () => { + it(`should ${expected} for ${JSON.stringify(input)} in format ${format}`, async () => { + const container = await setupRealContainer(); + await run("--version", container); let fail = false; + let result; try { - const result = colorize(input, { format }); + result = colorize(input, { format }); + } catch (e) { + fail = true; + } + expect(fail).to.equal(expected === "fail"); + if (!fail) { if (format !== Format.TEXT) { expect(result).to.not.equal(input); } else { @@ -39,10 +41,7 @@ describe("colorize", () => { } else { expect(stripAnsi(result)).to.not.equal(result); } - } catch (e) { - fail = true; } - expect(fail).to.equal(expected === "fail"); }); });