From 3f45954839608ddef30782e6b9909be0c8ce8772 Mon Sep 17 00:00:00 2001 From: Mark Michaelis Date: Tue, 10 Oct 2023 17:01:11 +0200 Subject: [PATCH] test: BBCodeColor --- .../__tests__/BBCodeColor.test.ts | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 packages/ckeditor5-bbcode/__tests__/BBCodeColor.test.ts diff --git a/packages/ckeditor5-bbcode/__tests__/BBCodeColor.test.ts b/packages/ckeditor5-bbcode/__tests__/BBCodeColor.test.ts new file mode 100644 index 0000000000..df46b181af --- /dev/null +++ b/packages/ckeditor5-bbcode/__tests__/BBCodeColor.test.ts @@ -0,0 +1,24 @@ +import { requireHTMLElement } from "./DOMUtils"; +import { bbCodeColor } from "../src/rules/BBCodeColor"; + +describe("BBCodeColor", () => { + describe("Default Configuration", () => { + const rule = bbCodeColor; + + it.each` + dataView | expected | comment + ${`TEXT`} | ${`[color=#ff0000]TEXT[/color]`} | ${`BBob HTML 5 Preset Result (toView)`} + ${`TEXT`} | ${`[color=#FF0000]TEXT[/color]`} | ${`ignore case`} + ${`TEXT`} | ${`[color=fuchsia]TEXT[/color]`} | ${`supported color names`} + ${`TEXT`} | ${`[color=#ccc]TEXT[/color]`} | ${`support shortened color codes`} + ${`TEXT`} | ${undefined} | ${`don't handle color codes, we cannot handle (yet?)`} + `( + "$[$#] Should process '$dataView' to '$expected' ($comment)", + ({ dataView, expected }: { dataView: string; expected: string | undefined }) => { + const element = requireHTMLElement(dataView); + const bbCode = rule.toData(element, element.textContent ?? ""); + expect(bbCode).toEqual(expected); + }, + ); + }); +});