mirror of
https://github.com/discourse/discourse.git
synced 2024-12-12 22:28:14 +08:00
94cf1c4786
Was "removing" (rather not re-applying) the `[spoiler]` BBCode because we were testing the **whole** class of the `span`/`div` was `spoiled` but we added another class and thus broke this functionnality. In order to fix this issue, the test to determine whether a `span`/`div` is a spoiler, now uses a regular expression to check whether the `class` **contains** the word `spoiled`. Reference - https://meta.discourse.org/t/quoting-spoiler-text-doesnt-include-spoiler-tags-in-the-quote/170145
31 lines
1.0 KiB
JavaScript
31 lines
1.0 KiB
JavaScript
import { test } from "qunit";
|
|
import { withPluginApi } from "discourse/lib/plugin-api";
|
|
import toMarkdown from "discourse/lib/to-markdown";
|
|
import { discourseModule } from "discourse/tests/helpers/qunit-helpers";
|
|
import { initializeSpoiler } from "discourse/plugins/spoiler-alert/initializers/spoiler-alert";
|
|
|
|
discourseModule("Spoiler Alert | Unit | to-markdown", function (hooks) {
|
|
hooks.beforeEach(function () {
|
|
withPluginApi("0.5", initializeSpoiler);
|
|
});
|
|
|
|
test("handles spoiler tags", function (assert) {
|
|
let html = `<div>Text with a</div><div class="spoiled spoiler-blurred">spoiled</div><div>word.</div>`;
|
|
let markdown = `Text with a\n\n[spoiler]\nspoiled\n[/spoiler]\n\nword.`;
|
|
|
|
assert.strictEqual(
|
|
toMarkdown(html),
|
|
markdown,
|
|
"it should create block spoiler tag"
|
|
);
|
|
|
|
html = `Inline <span class="spoiled">spoiled</span> word.`;
|
|
markdown = `Inline [spoiler]spoiled[/spoiler] word.`;
|
|
assert.strictEqual(
|
|
toMarkdown(html),
|
|
markdown,
|
|
"it should create inline spoiler tag"
|
|
);
|
|
});
|
|
});
|