/* Copyright 2026 Marimo. All rights reserved. */
import { AnsiUp } from "ansi_up";
import { describe, expect, test } from "vitest";
const ansiUp = new AnsiUp();
describe("ansi", () => {
test("basic", () => {
const text = "string";
const value = ansiUp.ansi_to_html(text);
expect(value).toMatchInlineSnapshot(`"string"`);
});
test("with ansi", () => {
const text = "'\u001B[30mblack\u001B[37mwhite'";
const value = ansiUp.ansi_to_html(text);
expect(value).toMatchInlineSnapshot(
`"'blackwhite'"`,
);
});
test("with html", () => {
// HTML gets escaped
const text = "string";
const value = ansiUp.ansi_to_html(text);
expect(value).toMatchInlineSnapshot(
`"<b>string</b>"`,
);
});
test("with ansi and html", () => {
// HTML gets escaped
const text = "'\u001B[1mstring\u001B[0m'";
const value = ansiUp.ansi_to_html(text);
expect(value).toMatchInlineSnapshot(
`"'<b>string</b>'"`,
);
});
});