-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
ace1727
commit 3f45954
Showing
1 changed file
with
24 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
}, | ||
); | ||
}); | ||
}); |