discourse/plugins/chat/test/javascripts/components/chat-user-avatar-test.js
Roman Rizzi 0a5f548635
DEV: Move discourse-chat to the core repo. (#18776)
As part of this move, we are also renaming `discourse-chat` to `chat`.
2022-11-02 10:41:30 -03:00

56 lines
1.5 KiB
JavaScript

import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import { exists } from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
import { module } from "qunit";
const user = {
id: 1,
username: "markvanlan",
name: null,
avatar_template: "/letter_avatar_proxy/v4/letter/m/48db29/{size}.png",
};
module("Discourse Chat | Component | chat-user-avatar", function (hooks) {
setupRenderingTest(hooks);
componentTest("user is not online", {
template: hbs`{{chat-user-avatar chat=chat user=user}}`,
async beforeEach() {
this.set("user", user);
this.set("chat", { presenceChannel: { users: [] } });
},
async test(assert) {
assert.ok(
exists(
`.chat-user-avatar .chat-user-avatar-container[data-user-card=${user.username}] .avatar[title=${user.username}]`
)
);
assert.notOk(exists(".chat-user-avatar.is-online"));
},
});
componentTest("user is online", {
template: hbs`{{chat-user-avatar chat=chat user=user}}`,
async beforeEach() {
this.set("user", user);
this.set("chat", {
presenceChannel: { users: [{ id: user.id }] },
});
},
async test(assert) {
assert.ok(
exists(
`.chat-user-avatar .chat-user-avatar-container[data-user-card=${user.username}] .avatar[title=${user.username}]`
)
);
assert.ok(exists(".chat-user-avatar.is-online"));
},
});
});