mirror of
https://github.com/discourse/discourse.git
synced 2024-12-27 09:43:52 +08:00
b81055a6d4
…to either qunit-dom or `strictEqual`
43 lines
1.4 KiB
Plaintext
43 lines
1.4 KiB
Plaintext
import { hash } from "@ember/helper";
|
|
import { getOwner } from "@ember/owner";
|
|
import { render } from "@ember/test-helpers";
|
|
import { module, test } from "qunit";
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
import formatChatDate from "discourse/plugins/chat/discourse/helpers/format-chat-date";
|
|
import ChatFabricators from "discourse/plugins/chat/discourse/lib/fabricators";
|
|
|
|
module("Discourse Chat | Unit | Helpers | format-chat-date", function (hooks) {
|
|
setupRenderingTest(hooks);
|
|
|
|
test("link to chat message", async function (assert) {
|
|
const channel = new ChatFabricators(getOwner(this)).channel();
|
|
const message = new ChatFabricators(getOwner(this)).message({ channel });
|
|
|
|
await render(<template>{{formatChatDate message}}</template>);
|
|
|
|
assert
|
|
.dom(".chat-time")
|
|
.hasAttribute("href", `/chat/c/-/${channel.id}/${message.id}`);
|
|
});
|
|
|
|
test("link to chat message thread", async function (assert) {
|
|
const channel = new ChatFabricators(getOwner(this)).channel();
|
|
const thread = new ChatFabricators(getOwner(this)).thread();
|
|
const message = new ChatFabricators(getOwner(this)).message({
|
|
channel,
|
|
thread,
|
|
});
|
|
|
|
await render(<template>
|
|
{{formatChatDate message (hash threadContext=true)}}
|
|
</template>);
|
|
|
|
assert
|
|
.dom(".chat-time")
|
|
.hasAttribute(
|
|
"href",
|
|
`/chat/c/-/${channel.id}/t/${thread.id}/${message.id}`
|
|
);
|
|
});
|
|
});
|