mirror of
https://github.com/discourse/discourse.git
synced 2025-05-22 17:13:25 +08:00
DEV: Move discourse-chat
to the core repo. (#18776)
As part of this move, we are also renaming `discourse-chat` to `chat`.
This commit is contained in:
@ -0,0 +1,76 @@
|
||||
import componentTest, {
|
||||
setupRenderingTest,
|
||||
} from "discourse/tests/helpers/component-test";
|
||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module } from "qunit";
|
||||
|
||||
function displayName() {
|
||||
return query(".chat-user-display-name").innerText.trim();
|
||||
}
|
||||
|
||||
module(
|
||||
"Discourse Chat | Component | chat-user-display-name | prioritize username in UX",
|
||||
function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
componentTest("username and no name", {
|
||||
template: hbs`{{chat-user-display-name user=user}}`,
|
||||
|
||||
async beforeEach() {
|
||||
this.siteSettings.prioritize_username_in_ux = true;
|
||||
this.set("user", { username: "bob", name: null });
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(displayName(), "bob");
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("username and name", {
|
||||
template: hbs`{{chat-user-display-name user=user}}`,
|
||||
|
||||
async beforeEach() {
|
||||
this.siteSettings.prioritize_username_in_ux = true;
|
||||
this.set("user", { username: "bob", name: "Bobcat" });
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(displayName(), "bob — Bobcat");
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
module(
|
||||
"Discourse Chat | Component | chat-user-display-name | prioritize name in UX",
|
||||
function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
componentTest("no name", {
|
||||
template: hbs`{{chat-user-display-name user=user}}`,
|
||||
|
||||
async beforeEach() {
|
||||
this.siteSettings.prioritize_username_in_ux = false;
|
||||
this.set("user", { username: "bob", name: null });
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(displayName(), "bob");
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("name and username", {
|
||||
template: hbs`{{chat-user-display-name user=user}}`,
|
||||
|
||||
async beforeEach() {
|
||||
this.siteSettings.prioritize_username_in_ux = false;
|
||||
this.set("user", { username: "bob", name: "Bobcat" });
|
||||
},
|
||||
|
||||
async test(assert) {
|
||||
assert.equal(displayName(), "Bobcat — bob");
|
||||
},
|
||||
});
|
||||
}
|
||||
);
|
Reference in New Issue
Block a user