import { describe, expect, it } from "vitest"; import { normalizeEditorText } from "./ckeditor-utils"; describe("normalizeEditorText", () => { it("converts null and undefined to empty string", () => { // GIVEN / WHEN / THEN expect(normalizeEditorText(null)).toBe(""); expect(normalizeEditorText(undefined)).toBe(""); }); it("converts string 'null' and 'undefined' to empty string", () => { // GIVEN / WHEN / THEN expect(normalizeEditorText("null")).toBe(""); expect(normalizeEditorText("undefined")).toBe(""); }); it("preserves valid empty string", () => { // GIVEN / WHEN / THEN expect(normalizeEditorText("")).toBe(""); }); it("preserves HTML and text content", () => { // GIVEN / WHEN / THEN expect(normalizeEditorText("
Hello world
")).toBe("Hello world
"); expect(normalizeEditorText("Some regular text")).toBe("Some regular text"); }); it("converts numbers to string", () => { // GIVEN / WHEN / THEN expect(normalizeEditorText(123)).toBe("123"); }); });