2024-06-24 18:33:24 +08:00
|
|
|
import { setupTest } from "ember-qunit";
|
2021-06-09 22:58:55 +08:00
|
|
|
import { module, test } from "qunit";
|
2023-11-07 00:59:49 +08:00
|
|
|
import { cook } from "discourse/lib/text";
|
2016-07-20 04:20:59 +08:00
|
|
|
|
2024-06-24 18:33:24 +08:00
|
|
|
module("lib:details-cooked-test", (hooks) => {
|
|
|
|
setupTest(hooks);
|
2016-07-20 04:20:59 +08:00
|
|
|
|
2024-06-24 18:33:24 +08:00
|
|
|
test("details", async (assert) => {
|
2023-11-07 00:59:49 +08:00
|
|
|
const testCooked = async (input, expected, text) => {
|
2024-06-24 18:33:24 +08:00
|
|
|
const cooked = (await cook(input)).toString();
|
2023-11-07 00:59:49 +08:00
|
|
|
assert.strictEqual(cooked, expected, text);
|
2022-06-20 21:42:10 +08:00
|
|
|
};
|
2024-06-24 18:33:24 +08:00
|
|
|
|
2023-11-07 00:59:49 +08:00
|
|
|
await testCooked(
|
2022-06-20 21:42:10 +08:00
|
|
|
`<details><summary>Info</summary>coucou</details>`,
|
|
|
|
`<details><summary>Info</summary>coucou</details>`,
|
|
|
|
"manual HTML for details"
|
2018-06-16 00:42:20 +08:00
|
|
|
);
|
2016-07-20 04:20:59 +08:00
|
|
|
|
2023-11-07 00:59:49 +08:00
|
|
|
await testCooked(
|
2024-06-24 18:33:24 +08:00
|
|
|
`[details=test'ing all the things]\ntest\n[/details]`,
|
|
|
|
`<details>\n<summary>\ntest'ing all the things</summary>\n<p>test</p>\n</details>`,
|
|
|
|
"details with spaces and a single quote"
|
|
|
|
);
|
|
|
|
|
|
|
|
await testCooked(
|
|
|
|
`[details=”test'ing all the things”]\ntest\n[/details]`,
|
|
|
|
`<details>\n<summary>\ntest'ing all the things</summary>\n<p>test</p>\n</details>`,
|
|
|
|
"details surrounded by finnish double quotes"
|
2022-06-20 21:42:10 +08:00
|
|
|
);
|
|
|
|
});
|
2016-07-21 01:26:23 +08:00
|
|
|
});
|