mirror of
https://github.com/discourse/discourse.git
synced 2026-08-09 21:45:25 +08:00
46 lines
1.5 KiB
Text
Vendored
46 lines
1.5 KiB
Text
Vendored
import { render } from "@ember/test-helpers";
|
|
import { module, test } from "qunit";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import Description from "../../discourse/components/discourse-post-event/description";
|
|
|
|
module("Integration | Component | Description", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test("renders plain text description", async function (assert) {
|
|
await render(
|
|
<template>
|
|
<Description @descriptionHtml="Just some plain text" />
|
|
</template>
|
|
);
|
|
|
|
assert.dom(".event-description__text").hasText("Just some plain text");
|
|
assert.dom(".event-description__text a").doesNotExist();
|
|
});
|
|
|
|
test("renders linkified description HTML", async function (assert) {
|
|
const html =
|
|
'Check out <a href="https://example.com">https://example.com</a> for details';
|
|
|
|
await render(
|
|
<template><Description @descriptionHtml={{html}} /></template>
|
|
);
|
|
|
|
assert
|
|
.dom(".event-description__text a")
|
|
.hasAttribute("href", "https://example.com")
|
|
.hasText("https://example.com");
|
|
});
|
|
|
|
test("falls back to plain text @description when @descriptionHtml is absent", async function (assert) {
|
|
await render(
|
|
<template>
|
|
<Description @description="Plain text via legacy argument" />
|
|
</template>
|
|
);
|
|
|
|
assert
|
|
.dom(".event-description__text")
|
|
.hasText("Plain text via legacy argument");
|
|
assert.dom(".event-description__text a").doesNotExist();
|
|
});
|
|
});
|