mirror of
https://github.com/discourse/discourse.git
synced 2024-12-15 17:23:44 +08:00
dc3473fe06
1. `test()` and `render()` instead of `componentTest()` 2. Angle brackets 3. `strictEqual()`/`true()`/`false()` assertions This removes all remaining uses of `componentTest` from core
63 lines
1.9 KiB
JavaScript
63 lines
1.9 KiB
JavaScript
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import hbs from "htmlbars-inline-precompile";
|
|
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
|
import { module, test } from "qunit";
|
|
import { render } from "@ember/test-helpers";
|
|
|
|
module("Discourse Chat | Component | chat-message-text", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test("yields", async function (assert) {
|
|
this.set("cooked", "<p></p>");
|
|
|
|
await render(hbs`
|
|
<ChatMessageText @cooked={{this.cooked}} @uploads={{this.uploads}}>
|
|
<div class="yield-me"></div>
|
|
</ChatMessageText>
|
|
`);
|
|
|
|
assert.true(exists(".yield-me"));
|
|
});
|
|
|
|
test("shows collapsed", async function (assert) {
|
|
this.set(
|
|
"cooked",
|
|
'<div class="onebox lazyYT lazyYT-container" data-youtube-id="WaT_rLGuUr8" data-youtube-title="Japanese Katsu Curry (Pork Cutlet)"/>'
|
|
);
|
|
|
|
await render(
|
|
hbs`<ChatMessageText @cooked={{this.cooked}} @uploads={{this.uploads}} />`
|
|
);
|
|
|
|
assert.true(exists(".chat-message-collapser"));
|
|
});
|
|
|
|
test("does not collapse a non-image onebox", async function (assert) {
|
|
this.set("cooked", '<p><a href="http://cat1.com" class="onebox"></a></p>');
|
|
|
|
await render(hbs`<ChatMessageText @cooked={{this.cooked}} />`);
|
|
|
|
assert.false(exists(".chat-message-collapser"));
|
|
});
|
|
|
|
test("shows edits - regular message", async function (assert) {
|
|
this.set("cooked", "<p></p>");
|
|
|
|
await render(
|
|
hbs`<ChatMessageText @cooked={{this.cooked}} @edited={{true}} />`
|
|
);
|
|
|
|
assert.true(exists(".chat-message-edited"));
|
|
});
|
|
|
|
test("shows edits - collapsible message", async function (assert) {
|
|
this.set("cooked", '<div class="onebox lazyYT-container"></div>');
|
|
|
|
await render(
|
|
hbs`<ChatMessageText @cooked={{this.cooked}} @edited={{true}} />`
|
|
);
|
|
|
|
assert.true(exists(".chat-message-edited"));
|
|
});
|
|
});
|