Skip to content

Commit

Permalink
test: BBCodeColor
Browse files Browse the repository at this point in the history
  • Loading branch information
mmichaelis committed Oct 10, 2023
1 parent ace1727 commit 3f45954
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions packages/ckeditor5-bbcode/__tests__/BBCodeColor.test.ts
Original file line number Diff line number Diff line change
@@ -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
${`<span style="color: #ff0000;">TEXT</span>`} | ${`[color=#ff0000]TEXT[/color]`} | ${`BBob HTML 5 Preset Result (toView)`}
${`<span style="color: #FF0000;">TEXT</span>`} | ${`[color=#FF0000]TEXT[/color]`} | ${`ignore case`}
${`<span style="color: fuchsia;">TEXT</span>`} | ${`[color=fuchsia]TEXT[/color]`} | ${`supported color names`}
${`<span style="color: #ccc;">TEXT</span>`} | ${`[color=#ccc]TEXT[/color]`} | ${`support shortened color codes`}
${`<span style="color: rgb(255, 0, 0);">TEXT</span>`} | ${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);
},
);
});
});

0 comments on commit 3f45954

Please sign in to comment.