feat : update excel
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
applyRichTextStylePatch,
|
||||
normalizeExtraRichText,
|
||||
richTextContentSignature,
|
||||
sanitizeRichTextHtml,
|
||||
sanitizeRichTextUrl,
|
||||
} from "@/lib/rich-text";
|
||||
@@ -46,3 +48,35 @@ describe("legacy Extra rich text conversion", () => {
|
||||
])).toBe("<p><em>Ready</em></p>");
|
||||
});
|
||||
});
|
||||
|
||||
describe("bulk rich-text styles", () => {
|
||||
it("applies a style to every text node without replacing structure or links", () => {
|
||||
expect(applyRichTextStylePatch(
|
||||
'<p>First <a href="https://example.com">link</a></p><ul><li>Second</li></ul>',
|
||||
{ bold: true },
|
||||
)).toBe(
|
||||
'<p><strong>First </strong><a href="https://example.com" target="_blank" rel="noopener noreferrer"><strong>link</strong></a></p><ul><li><strong>Second</strong></li></ul>',
|
||||
);
|
||||
});
|
||||
|
||||
it("removes only requested styles and applies normalized colors", () => {
|
||||
expect(applyRichTextStylePatch(
|
||||
'<p><strong>Bold <em>and italic</em></strong></p>',
|
||||
{ bold: false },
|
||||
)).toBe("<p>Bold <em>and italic</em></p>");
|
||||
expect(applyRichTextStylePatch("<p>Red</p>", { color: "#00ff00" }))
|
||||
.toBe('<p><span style="color: #00FF00">Red</span></p>');
|
||||
expect(applyRichTextStylePatch(
|
||||
'<p><span style="color: #00FF00">Green</span></p>',
|
||||
{ color: null },
|
||||
)).toBe("<p>Green</p>");
|
||||
});
|
||||
|
||||
it("compares content independently from visual formatting", () => {
|
||||
expect(richTextContentSignature(
|
||||
'<p><strong>Same</strong> <span style="color: #FF0000">text</span></p>',
|
||||
)).toBe("<p>Same text</p>");
|
||||
expect(richTextContentSignature("<p>Changed text</p>"))
|
||||
.not.toBe(richTextContentSignature("<p>Original text</p>"));
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user