2024-06-24 05:33:24 -05:00
|
|
|
import { setupTest } from "ember-qunit";
|
2021-06-09 09:58:55 -05:00
|
|
|
import { module, test } from "qunit";
|
2023-11-06 10:59:49 -06:00
|
|
|
import { cook } from "discourse/lib/text";
|
2016-07-19 15:20:59 -05:00
|
|
|
|
2024-06-24 05:33:24 -05:00
|
|
|
module("lib:details-cooked-test", (hooks) => {
|
|
|
|
setupTest(hooks);
|
2016-07-19 15:20:59 -05:00
|
|
|
|
2024-06-24 05:33:24 -05:00
|
|
|
test("details", async (assert) => {
|
2023-11-06 10:59:49 -06:00
|
|
|
const testCooked = async (input, expected, text) => {
|
2024-06-24 05:33:24 -05:00
|
|
|
const cooked = (await cook(input)).toString();
|
2023-11-06 10:59:49 -06:00
|
|
|
assert.strictEqual(cooked, expected, text);
|
2022-06-20 08:42:10 -05:00
|
|
|
};
|
2024-06-24 05:33:24 -05:00
|
|
|
|
2023-11-06 10:59:49 -06:00
|
|
|
await testCooked(
|
2022-06-20 08:42:10 -05:00
|
|
|
`<details><summary>Info</summary>coucou</details>`,
|
|
|
|
`<details><summary>Info</summary>coucou</details>`,
|
|
|
|
"manual HTML for details"
|
2018-06-15 11:42:20 -05:00
|
|
|
);
|
2016-07-19 15:20:59 -05:00
|
|
|
|
2023-11-06 10:59:49 -06:00
|
|
|
await testCooked(
|
2024-06-24 05:33:24 -05: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 08:42:10 -05:00
|
|
|
);
|
|
|
|
});
|
2016-07-20 12:26:23 -05:00
|
|
|
});
|