mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 11:23:25 +08:00
DEV: Convert more equal
assertions (#29554)
…to either qunit-dom or `strictEqual`
This commit is contained in:
parent
d2056c7fc6
commit
b81055a6d4
|
@ -198,7 +198,7 @@ acceptance("Admin - Site Settings", function (needs) {
|
|||
|
||||
const navItems = queryAll(".admin-nav .nav-stacked li a");
|
||||
navItems.each((_, item) => {
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
item.title,
|
||||
item.innerText,
|
||||
"menu item has title, and the title is equal to menu item's label"
|
||||
|
|
|
@ -22,10 +22,7 @@ acceptance("Admin - Users List", function (needs) {
|
|||
|
||||
await fillIn(".controls.username input", "doesntexist");
|
||||
|
||||
assert.equal(
|
||||
query(".users-list-container").innerText,
|
||||
I18n.t("search.no_results")
|
||||
);
|
||||
assert.dom(".users-list-container").hasText(I18n.t("search.no_results"));
|
||||
});
|
||||
|
||||
test("sorts users", async function (assert) {
|
||||
|
|
|
@ -119,13 +119,9 @@ acceptance("Composer - editor mentions", function (needs) {
|
|||
.dom(`.autocomplete .emoji[alt='${status.emoji}']`)
|
||||
.exists("status emoji is shown");
|
||||
|
||||
assert.equal(
|
||||
query(
|
||||
".autocomplete .user-status-message-description"
|
||||
).textContent.trim(),
|
||||
status.description,
|
||||
"status description is shown"
|
||||
);
|
||||
assert
|
||||
.dom(".autocomplete .user-status-message-description")
|
||||
.hasText(status.description, "status description is shown");
|
||||
});
|
||||
|
||||
test("metadata matches are moved to the end", async function (assert) {
|
||||
|
|
|
@ -125,11 +125,7 @@ acceptance("flagging", function (needs) {
|
|||
await selectKit(".reviewable-action-dropdown").expand();
|
||||
await click("[data-value='agree_and_silence']");
|
||||
assert.ok(exists(".silence-user-modal"), "it shows the silence modal");
|
||||
assert.equal(
|
||||
query(".suspend-message").value,
|
||||
"",
|
||||
"penalty message is empty"
|
||||
);
|
||||
assert.dom(".suspend-message").hasValue("", "penalty message is empty");
|
||||
const silenceUntilCombobox = selectKit(".silence-until .combobox");
|
||||
await silenceUntilCombobox.expand();
|
||||
await silenceUntilCombobox.selectRowByValue("tomorrow");
|
||||
|
@ -148,11 +144,12 @@ acceptance("flagging", function (needs) {
|
|||
await selectKit(".reviewable-action-dropdown").expand();
|
||||
await click("[data-value='agree_and_silence']");
|
||||
assert.ok(exists(".silence-user-modal"), "it shows the silence modal");
|
||||
assert.equal(
|
||||
query(".suspend-message").value,
|
||||
"-------------------\n<p>Any plans to support localization of UI elements, so that I (for example) could set up a completely German speaking forum?</p>\n-------------------",
|
||||
"penalty message is prefilled with post text"
|
||||
);
|
||||
assert
|
||||
.dom(".suspend-message")
|
||||
.hasValue(
|
||||
"-------------------\n<p>Any plans to support localization of UI elements, so that I (for example) could set up a completely German speaking forum?</p>\n-------------------",
|
||||
"penalty message is prefilled with post text"
|
||||
);
|
||||
});
|
||||
|
||||
test("Can delete spammer from spam", async function (assert) {
|
||||
|
|
|
@ -121,7 +121,10 @@ acceptance("Managing Group Membership", function (needs) {
|
|||
await associatedGroups.selectRowByName("google_oauth2:test-group");
|
||||
await associatedGroups.keyboard("enter");
|
||||
|
||||
assert.equal(associatedGroups.header().name(), "google_oauth2:test-group");
|
||||
assert.strictEqual(
|
||||
associatedGroups.header().name(),
|
||||
"google_oauth2:test-group"
|
||||
);
|
||||
});
|
||||
|
||||
test("As an admin on a site that can't associate groups", async function (assert) {
|
||||
|
|
|
@ -177,11 +177,9 @@ acceptance("Post inline mentions – user status tooltip", function (needs) {
|
|||
statusTooltip.querySelector("img").src.includes(status.emoji),
|
||||
"emoji is correct"
|
||||
);
|
||||
assert.equal(
|
||||
statusTooltip.querySelector(".user-status-tooltip-description").innerText,
|
||||
status.description,
|
||||
"status description is correct"
|
||||
);
|
||||
assert
|
||||
.dom(".user-status-tooltip-description", statusTooltip)
|
||||
.hasText(status.description, "status description is correct");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -801,7 +801,7 @@ acceptance("Sidebar - Logged on user - Community Section", function (needs) {
|
|||
"shows suffix indicator for new topics on categories link"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
Object.keys(topicTrackingState.stateChangeCallbacks).length,
|
||||
initialCallbackCount,
|
||||
"it does not add a new topic tracking state callback when the topic is read"
|
||||
|
|
|
@ -222,11 +222,9 @@ acceptance("Theme", function (needs) {
|
|||
|
||||
await click(".control-unit .btn-primary.finish-install");
|
||||
|
||||
assert.equal(
|
||||
query(".show-current-style .title span").innerText,
|
||||
"discourse-complete-theme",
|
||||
"it updates theme title"
|
||||
);
|
||||
assert
|
||||
.dom(".show-current-style .title span")
|
||||
.hasText("discourse-complete-theme", "it updates theme title");
|
||||
|
||||
assert.notOk(
|
||||
query(".metadata.control-unit").innerText.includes(
|
||||
|
|
|
@ -308,10 +308,7 @@ acceptance("User Preferences — Account - Download Archive", function (needs) {
|
|||
await click(".btn-request-archive");
|
||||
await click("#dialog-holder .btn-primary");
|
||||
|
||||
assert.equal(
|
||||
query(".dialog-body").innerText.trim(),
|
||||
I18n.t("user.download_archive.success")
|
||||
);
|
||||
assert.dom(".dialog-body").hasText(I18n.t("user.download_archive.success"));
|
||||
|
||||
await click("#dialog-holder .btn-primary");
|
||||
});
|
||||
|
|
|
@ -3,7 +3,7 @@ import { hbs } from "ember-cli-htmlbars";
|
|||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import pretender, { response } from "discourse/tests/helpers/create-pretender";
|
||||
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
module(
|
||||
"Integration | Component | form-template-field | wrapper",
|
||||
|
@ -60,26 +60,23 @@ module(
|
|||
- type: multi-select\n id: multi\n choices:\n - "Option 1"\n - "Option 2"\n - "Option 3"`;
|
||||
this.set("content", content);
|
||||
|
||||
const initialValues = {
|
||||
this.set("initialValues", {
|
||||
checkbox: "on",
|
||||
name: "Test Name",
|
||||
notes: "Test Notes",
|
||||
dropdown: "Option 1",
|
||||
multi: ["Option 1"],
|
||||
};
|
||||
this.set("initialValues", initialValues);
|
||||
});
|
||||
|
||||
await render(
|
||||
hbs`<FormTemplateField::Wrapper @content={{this.content}} @initialValues={{this.initialValues}} />`
|
||||
);
|
||||
|
||||
Object.keys(initialValues).forEach((componentId) => {
|
||||
assert.equal(
|
||||
query(`[name='${componentId}']`).value,
|
||||
initialValues[componentId],
|
||||
`${componentId} component has initial value`
|
||||
);
|
||||
});
|
||||
assert.dom("[name='checkbox']").hasValue("on");
|
||||
assert.dom("[name='name']").hasValue("Test Name");
|
||||
assert.dom("[name='notes']").hasValue("Test Notes");
|
||||
assert.dom("[name='dropdown']").hasValue("Option 1");
|
||||
assert.dom("[name='multi']").hasValue("Option 1");
|
||||
});
|
||||
|
||||
test("renders a component based on the component type found in the content YAML when passed ids", async function (assert) {
|
||||
|
|
|
@ -18,7 +18,7 @@ module("Integration | Component | number-field", function (hooks) {
|
|||
|
||||
await fillIn(".number-field-test", "33");
|
||||
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
this.get("value"),
|
||||
33,
|
||||
"value is changed when the input is a valid number"
|
||||
|
@ -27,7 +27,7 @@ module("Integration | Component | number-field", function (hooks) {
|
|||
await fillIn(".number-field-test", "");
|
||||
await triggerKeyEvent(".number-field-test", "keydown", 66); // b
|
||||
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
this.get("value"),
|
||||
"",
|
||||
"value is cleared when the input is NaN"
|
||||
|
@ -46,7 +46,7 @@ module("Integration | Component | number-field", function (hooks) {
|
|||
await triggerKeyEvent(".number-field-test", "keydown", 189); // -
|
||||
await triggerKeyEvent(".number-field-test", "keydown", 49); // 1
|
||||
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
this.get("value"),
|
||||
"",
|
||||
"value is cleared when the input is less than the min"
|
||||
|
@ -60,9 +60,9 @@ module("Integration | Component | number-field", function (hooks) {
|
|||
|
||||
await fillIn(".number-field-test", "-1");
|
||||
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
this.get("value"),
|
||||
"-1",
|
||||
-1,
|
||||
"negative input allowed when min is negative"
|
||||
);
|
||||
});
|
||||
|
|
|
@ -43,12 +43,12 @@ module(
|
|||
await this.subject.expand();
|
||||
await this.subject.fillInFilter("Parent Category");
|
||||
|
||||
assert.equal(this.subject.rows().length, 2);
|
||||
assert.equal(
|
||||
assert.strictEqual(this.subject.rows().length, 2);
|
||||
assert.strictEqual(
|
||||
this.subject.rowByIndex(0).el().innerText.replace("\n", " "),
|
||||
"Parent Category × 95"
|
||||
);
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
this.subject.rowByIndex(1).el().innerText.replaceAll("\n", " "),
|
||||
"Parent Category × 95 +2 subcategories"
|
||||
);
|
||||
|
|
|
@ -133,18 +133,12 @@ module(
|
|||
await fillIn(".filter-input", "test-user");
|
||||
|
||||
assert.ok(exists(".user-status-message"), "user status is rendered");
|
||||
assert.equal(
|
||||
query(".user-status-message .emoji").alt,
|
||||
status.emoji,
|
||||
"status emoji is correct"
|
||||
);
|
||||
assert.equal(
|
||||
query(
|
||||
".user-status-message .user-status-message-description"
|
||||
).innerText.trim(),
|
||||
status.description,
|
||||
"status description is correct"
|
||||
);
|
||||
assert
|
||||
.dom(".user-status-message .emoji")
|
||||
.hasAttribute("alt", status.emoji, "status emoji is correct");
|
||||
assert
|
||||
.dom(".user-status-message .user-status-message-description")
|
||||
.hasText(status.description, "status description is correct");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
|
|
@ -130,7 +130,7 @@ module(
|
|||
|
||||
await this.subject.fillInFilter("test");
|
||||
|
||||
assert.equal(this.subject.filter().value(), "#test");
|
||||
assert.strictEqual(this.subject.filter().value(), "#test");
|
||||
assert.ok(
|
||||
exists(".select-kit-row[data-value='test']"),
|
||||
"it filters out the invalid char from the suggested tag"
|
||||
|
|
|
@ -116,7 +116,7 @@ module("Integration | Component | select-kit/multi-select", function (hooks) {
|
|||
await this.subject.expand();
|
||||
await paste(query(".filter-input"), "foo|bar");
|
||||
|
||||
assert.equal(this.subject.header().value(), "1,2");
|
||||
assert.strictEqual(this.subject.header().value(), "1,2");
|
||||
});
|
||||
|
||||
test("no value property with no content", async function (assert) {
|
||||
|
|
|
@ -107,9 +107,9 @@ module("Unit | Controller | admin-user-badges", function (hooks) {
|
|||
GrantBadgeStub.calledWith(badgeToGrant.id, user.username, badgeReason)
|
||||
);
|
||||
|
||||
assert.equal(controller.badgeReason, "");
|
||||
assert.equal(controller.userBadges.length, 1);
|
||||
assert.equal(controller.userBadges[0].id, newUserBadge.id);
|
||||
assert.equal(controller.selectedBadgeId, otherBadge.id);
|
||||
assert.strictEqual(controller.badgeReason, "");
|
||||
assert.strictEqual(controller.userBadges.length, 1);
|
||||
assert.strictEqual(controller.userBadges[0].id, newUserBadge.id);
|
||||
assert.strictEqual(controller.selectedBadgeId, otherBadge.id);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,23 +10,26 @@ module("Unit | discourse-common | case-converter", function (hooks) {
|
|||
setupTest(hooks);
|
||||
|
||||
test("camelCaseToSnakeCase", function (assert) {
|
||||
assert.equal(camelCaseToSnakeCase("camelCase"), "camel_case");
|
||||
assert.equal(camelCaseToSnakeCase("camelCase99"), "camel_case99");
|
||||
assert.equal(camelCaseToSnakeCase("camelCaseId"), "camel_case_id");
|
||||
assert.equal(camelCaseToSnakeCase("camelCaseUrl"), "camel_case_url");
|
||||
assert.strictEqual(camelCaseToSnakeCase("camelCase"), "camel_case");
|
||||
assert.strictEqual(camelCaseToSnakeCase("camelCase99"), "camel_case99");
|
||||
assert.strictEqual(camelCaseToSnakeCase("camelCaseId"), "camel_case_id");
|
||||
assert.strictEqual(camelCaseToSnakeCase("camelCaseUrl"), "camel_case_url");
|
||||
});
|
||||
|
||||
test("camelCaseToDash", function (assert) {
|
||||
assert.equal(camelCaseToDash("camelCase"), "camel-case");
|
||||
assert.equal(camelCaseToDash("camelCaseToDash99"), "camel-case-to-dash99");
|
||||
assert.equal(camelCaseToDash("camelCaseId"), "camel-case-id");
|
||||
assert.equal(camelCaseToDash("camelCaseUrl"), "camel-case-url");
|
||||
assert.strictEqual(camelCaseToDash("camelCase"), "camel-case");
|
||||
assert.strictEqual(
|
||||
camelCaseToDash("camelCaseToDash99"),
|
||||
"camel-case-to-dash99"
|
||||
);
|
||||
assert.strictEqual(camelCaseToDash("camelCaseId"), "camel-case-id");
|
||||
assert.strictEqual(camelCaseToDash("camelCaseUrl"), "camel-case-url");
|
||||
});
|
||||
|
||||
test("snakeCaseToCamelCase", function (assert) {
|
||||
assert.equal(snakeCaseToCamelCase("snake_case"), "snakeCase");
|
||||
assert.equal(snakeCaseToCamelCase("snake_case99"), "snakeCase99");
|
||||
assert.equal(snakeCaseToCamelCase("some_id"), "someId");
|
||||
assert.equal(snakeCaseToCamelCase("some_url"), "someUrl");
|
||||
assert.strictEqual(snakeCaseToCamelCase("snake_case"), "snakeCase");
|
||||
assert.strictEqual(snakeCaseToCamelCase("snake_case99"), "snakeCase99");
|
||||
assert.strictEqual(snakeCaseToCamelCase("some_id"), "someId");
|
||||
assert.strictEqual(snakeCaseToCamelCase("some_url"), "someUrl");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -39,7 +39,7 @@ module("Unit | Utility | download-calendar", function (hooks) {
|
|||
}
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
data,
|
||||
`BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
|
@ -76,7 +76,7 @@ END:VCALENDAR`
|
|||
],
|
||||
{ recurrenceRule: "FREQ=DAILY;BYDAY=MO,TU,WE,TH,FR" }
|
||||
);
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
data,
|
||||
`BEGIN:VCALENDAR
|
||||
VERSION:2.0
|
||||
|
|
|
@ -492,14 +492,14 @@ module("Unit | Utility | formatter | until", function (hooks) {
|
|||
const timezone = "UTC";
|
||||
this.clock = fakeTime("2100-01-01 12:00:00.000Z", timezone);
|
||||
const result = until("2100-01-01 13:00:00.000Z", timezone, "en");
|
||||
assert.equal(result, "Until: 1:00 PM");
|
||||
assert.strictEqual(result, "Until: 1:00 PM");
|
||||
});
|
||||
|
||||
test("shows date if until moment is tomorrow", function (assert) {
|
||||
const timezone = "UTC";
|
||||
this.clock = fakeTime("2100-01-01 12:00:00.000Z", timezone);
|
||||
const result = until("2100-01-02 12:00:00.000Z", timezone, "en");
|
||||
assert.equal(result, "Until: Jan 2");
|
||||
assert.strictEqual(result, "Until: Jan 2");
|
||||
});
|
||||
|
||||
test("shows until moment in user's timezone", function (assert) {
|
||||
|
@ -510,6 +510,6 @@ module("Unit | Utility | formatter | until", function (hooks) {
|
|||
this.clock = fakeTime("2100-01-01 12:00:00.000Z", timezone);
|
||||
const result = until(`2100-01-01 ${untilUTC}:00.000Z`, timezone, "en");
|
||||
|
||||
assert.equal(result, `Until: ${untilTbilisi}`);
|
||||
assert.strictEqual(result, `Until: ${untilTbilisi}`);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -70,6 +70,6 @@ module("Unit | Utility | text | parseMentions", function (hooks) {
|
|||
\`\`\`
|
||||
`;
|
||||
const mentions = await parseMentions(markdown);
|
||||
assert.equal(mentions.length, 0);
|
||||
assert.strictEqual(mentions.length, 0);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -28,8 +28,8 @@ module("Unit | Model | category", function (hooks) {
|
|||
});
|
||||
|
||||
assert.deepEqual(foo.subcategories, [bar, baz]);
|
||||
assert.equal(bar.parentCategory, foo);
|
||||
assert.equal(baz.parentCategory, foo);
|
||||
assert.strictEqual(bar.parentCategory, foo);
|
||||
assert.strictEqual(baz.parentCategory, foo);
|
||||
});
|
||||
|
||||
test("slugFor", function (assert) {
|
||||
|
|
|
@ -454,7 +454,7 @@ module("Unit | Model | composer", function (hooks) {
|
|||
pretender.post("/posts", function (request) {
|
||||
const data = parsePostData(request.requestBody);
|
||||
|
||||
assert.equal(data.meta_data.some_custom_field, "some_value");
|
||||
assert.strictEqual(data.meta_data.some_custom_field, "some_value");
|
||||
saved = true;
|
||||
|
||||
return response(200, {
|
||||
|
@ -478,11 +478,11 @@ module("Unit | Model | composer", function (hooks) {
|
|||
draftSequence: 1,
|
||||
});
|
||||
|
||||
assert.equal(composer.loading, false);
|
||||
assert.false(composer.loading);
|
||||
|
||||
composer.metaData = { some_custom_field: "some_value" };
|
||||
await composer.save({});
|
||||
|
||||
assert.equal(saved, true);
|
||||
assert.true(saved);
|
||||
});
|
||||
});
|
||||
|
|
|
@ -373,7 +373,7 @@ module("Unit | Model | topic-tracking-state", function (hooks) {
|
|||
"expect state for topic 111 to be deleted"
|
||||
);
|
||||
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
stateChangeCallbackCalledTimes,
|
||||
1,
|
||||
"callback is only called once"
|
||||
|
|
|
@ -2,7 +2,7 @@ import { render } from "@ember/test-helpers";
|
|||
import { hbs } from "ember-cli-htmlbars";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { exists, query } from "discourse/tests/helpers/qunit-helpers";
|
||||
import { exists } from "discourse/tests/helpers/qunit-helpers";
|
||||
|
||||
module("Integration | Component | email-group-user-field", function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
@ -12,7 +12,7 @@ module("Integration | Component | email-group-user-field", function (hooks) {
|
|||
|
||||
await render(template);
|
||||
|
||||
assert.equal(query(".control-label").innerText, "a label");
|
||||
assert.dom(".control-label").hasText("a label");
|
||||
assert.ok(
|
||||
exists(
|
||||
".controls details.select-kit.multi-select.user-chooser.email-group-user-chooser"
|
||||
|
|
|
@ -62,7 +62,7 @@ acceptance("Discourse Chat - Composer", function (needs) {
|
|||
|
||||
await settled();
|
||||
|
||||
assert.equal(document.querySelector(".chat-composer__input").value, "Foo");
|
||||
assert.dom(".chat-composer__input").hasValue("Foo");
|
||||
});
|
||||
});
|
||||
|
||||
|
|
|
@ -161,20 +161,18 @@ module(
|
|||
await render(hbs`<ChatChannel @channel={{this.channel}} /><DTooltips />`);
|
||||
await triggerEvent(statusSelector(mentionedUser.username), "mousemove");
|
||||
|
||||
assert.equal(
|
||||
document
|
||||
.querySelector(".user-status-tooltip-description")
|
||||
.textContent.trim(),
|
||||
mentionedUser.status.description,
|
||||
"status description is correct"
|
||||
);
|
||||
assert
|
||||
.dom(".user-status-tooltip-description")
|
||||
.hasText(
|
||||
mentionedUser.status.description,
|
||||
"status description is correct"
|
||||
);
|
||||
|
||||
assert.ok(
|
||||
document.querySelector(
|
||||
assert
|
||||
.dom(
|
||||
`.user-status-message-tooltip img[alt='${mentionedUser.status.emoji}']`
|
||||
),
|
||||
"status emoji is correct"
|
||||
);
|
||||
)
|
||||
.exists("status emoji is correct");
|
||||
});
|
||||
|
||||
function assertStatusIsRendered(assert, selector, status) {
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
import { hash } from "@ember/helper";
|
||||
import { getOwner } from "@ember/owner";
|
||||
import { render } from "@ember/test-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import { query } from "discourse/tests/helpers/qunit-helpers";
|
||||
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) {
|
||||
|
@ -11,31 +11,32 @@ module("Discourse Chat | Unit | Helpers | format-chat-date", function (hooks) {
|
|||
|
||||
test("link to chat message", async function (assert) {
|
||||
const channel = new ChatFabricators(getOwner(this)).channel();
|
||||
this.message = new ChatFabricators(getOwner(this)).message({ channel });
|
||||
const message = new ChatFabricators(getOwner(this)).message({ channel });
|
||||
|
||||
await render(hbs`{{format-chat-date this.message}}`);
|
||||
await render(<template>{{formatChatDate message}}</template>);
|
||||
|
||||
assert.equal(
|
||||
query(".chat-time").getAttribute("href"),
|
||||
`/chat/c/-/${channel.id}/${this.message.id}`
|
||||
);
|
||||
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();
|
||||
this.message = new ChatFabricators(getOwner(this)).message({
|
||||
const message = new ChatFabricators(getOwner(this)).message({
|
||||
channel,
|
||||
thread,
|
||||
});
|
||||
|
||||
await render(
|
||||
hbs`{{format-chat-date this.message (hash threadContext=true)}}`
|
||||
);
|
||||
await render(<template>
|
||||
{{formatChatDate message (hash threadContext=true)}}
|
||||
</template>);
|
||||
|
||||
assert.equal(
|
||||
query(".chat-time").getAttribute("href"),
|
||||
`/chat/c/-/${channel.id}/t/${thread.id}/${this.message.id}`
|
||||
);
|
||||
assert
|
||||
.dom(".chat-time")
|
||||
.hasAttribute(
|
||||
"href",
|
||||
`/chat/c/-/${channel.id}/t/${thread.id}/${message.id}`
|
||||
);
|
||||
});
|
||||
});
|
|
@ -0,0 +1,41 @@
|
|||
import { render } from "@ember/test-helpers";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
import tonableEmojiTitle from "discourse/plugins/chat/discourse/helpers/tonable-emoji-title";
|
||||
|
||||
module(
|
||||
"Discourse Chat | Unit | Helpers | tonable-emoji-title",
|
||||
function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test("When emoji is not tonable", async function (assert) {
|
||||
const emoji = { name: "foo", tonable: false };
|
||||
const diversity = 1;
|
||||
await render(<template>
|
||||
<span>{{tonableEmojiTitle emoji diversity}}</span>
|
||||
</template>);
|
||||
|
||||
assert.dom("span").hasText(":foo:");
|
||||
});
|
||||
|
||||
test("When emoji is tonable and diversity is 1", async function (assert) {
|
||||
const emoji = { name: "foo", tonable: true };
|
||||
const diversity = 1;
|
||||
await render(<template>
|
||||
<span>{{tonableEmojiTitle emoji diversity}}</span>
|
||||
</template>);
|
||||
|
||||
assert.dom("span").hasText(":foo:");
|
||||
});
|
||||
|
||||
test("When emoji is tonable and diversity is greater than 1", async function (assert) {
|
||||
const emoji = { name: "foo", tonable: true };
|
||||
const diversity = 2;
|
||||
await render(<template>
|
||||
<span>{{tonableEmojiTitle emoji diversity}}</span>
|
||||
</template>);
|
||||
|
||||
assert.dom("span").hasText(":foo:t2:");
|
||||
});
|
||||
}
|
||||
);
|
|
@ -1,44 +0,0 @@
|
|||
import { render } from "@ember/test-helpers";
|
||||
import hbs from "htmlbars-inline-precompile";
|
||||
import { module, test } from "qunit";
|
||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||
|
||||
module(
|
||||
"Discourse Chat | Unit | Helpers | tonable-emoji-title",
|
||||
function (hooks) {
|
||||
setupRenderingTest(hooks);
|
||||
|
||||
test("When emoji is not tonable", async function (assert) {
|
||||
this.set("emoji", { name: "foo", tonable: false });
|
||||
this.set("diversity", 1);
|
||||
await render(hbs`{{tonable-emoji-title this.emoji this.diversity}}`);
|
||||
|
||||
assert.equal(
|
||||
document.querySelector("#ember-testing").innerText.trim(),
|
||||
":foo:"
|
||||
);
|
||||
});
|
||||
|
||||
test("When emoji is tonable and diversity is 1", async function (assert) {
|
||||
this.set("emoji", { name: "foo", tonable: true });
|
||||
this.set("diversity", 1);
|
||||
await render(hbs`{{tonable-emoji-title this.emoji this.diversity}}`);
|
||||
|
||||
assert.equal(
|
||||
document.querySelector("#ember-testing").innerText.trim(),
|
||||
":foo:"
|
||||
);
|
||||
});
|
||||
|
||||
test("When emoji is tonable and diversity is greater than 1", async function (assert) {
|
||||
this.set("emoji", { name: "foo", tonable: true });
|
||||
this.set("diversity", 2);
|
||||
await render(hbs`{{tonable-emoji-title this.emoji this.diversity}}`);
|
||||
|
||||
assert.equal(
|
||||
document.querySelector("#ember-testing").innerText.trim(),
|
||||
":foo:t2:"
|
||||
);
|
||||
});
|
||||
}
|
||||
);
|
|
@ -28,8 +28,8 @@ module("Discourse Chat | Unit | chat-composer-buttons", function (hooks) {
|
|||
|
||||
test("chatComposerButtons", function (assert) {
|
||||
const button = chatComposerButtons({ baz: "fooz" }, "inline")[1];
|
||||
assert.equal(button.id, "bar");
|
||||
assert.equal(button.label, "fooz");
|
||||
assert.strictEqual(button.id, "bar");
|
||||
assert.strictEqual(button.label, "fooz");
|
||||
});
|
||||
|
||||
test("chatComposerButtonsDependentKeys", function (assert) {
|
||||
|
|
|
@ -3,14 +3,14 @@ import slugifyChannel from "discourse/plugins/chat/discourse/lib/slugify-channel
|
|||
|
||||
module("Discourse Chat | Unit | slugify-channel", function () {
|
||||
test("defaults for title", function (assert) {
|
||||
assert.equal(slugifyChannel({ title: "Foo bar" }), "foo-bar");
|
||||
assert.strictEqual(slugifyChannel({ title: "Foo bar" }), "foo-bar");
|
||||
});
|
||||
|
||||
test("a very long name for the title", function (assert) {
|
||||
const string =
|
||||
"xAq8l5ca2CtEToeMLe2pEr2VUGQBx3HPlxbkDExKrJHp4f7jCVw9id1EQv1N1lYMRdAIiZNnn94Kr0uU0iiEeVO4XkBVmpW8Mknmd";
|
||||
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
slugifyChannel({ title: string }),
|
||||
string.toLowerCase().slice(0, -1)
|
||||
);
|
||||
|
@ -19,18 +19,18 @@ module("Discourse Chat | Unit | slugify-channel", function () {
|
|||
test("a cyrillic name for the title", function (assert) {
|
||||
const string = "Русская литература и фольклор";
|
||||
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
slugifyChannel({ title: string }),
|
||||
"русская-литература-и-фольклор"
|
||||
);
|
||||
});
|
||||
|
||||
test("channel has escapedTitle", function (assert) {
|
||||
assert.equal(slugifyChannel({ escapedTitle: "Foo bar" }), "foo-bar");
|
||||
assert.strictEqual(slugifyChannel({ escapedTitle: "Foo bar" }), "foo-bar");
|
||||
});
|
||||
|
||||
test("channel has slug and title", function (assert) {
|
||||
assert.equal(
|
||||
assert.strictEqual(
|
||||
slugifyChannel({ title: "Foo bar", slug: "some-other-thing" }),
|
||||
"some-other-thing",
|
||||
"slug takes priority"
|
||||
|
|
|
@ -31,7 +31,10 @@ module("Chat | Unit | Utility | plugin-api", function (hooks) {
|
|||
test("#removeChatComposerSecondaryActions", async function (assert) {
|
||||
withPluginApi("1.1.0", async (api) => {
|
||||
// assert that the api method is defined
|
||||
assert.equal(typeof api.removeChatComposerSecondaryActions, "function");
|
||||
assert.strictEqual(
|
||||
typeof api.removeChatComposerSecondaryActions,
|
||||
"function"
|
||||
);
|
||||
|
||||
logIn();
|
||||
const currentUser = User.current();
|
||||
|
|
|
@ -48,14 +48,8 @@ module("Unit | discourse-local-dates", function (hooks) {
|
|||
discourse_local_dates_enabled: true,
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
from.querySelector(".relative-time").textContent,
|
||||
"Yesterday 5:21 PM"
|
||||
);
|
||||
assert.equal(
|
||||
to.querySelector(".relative-time").textContent,
|
||||
"10:22 PM (Singapore)"
|
||||
);
|
||||
assert.dom(".relative-time", from).hasText("Yesterday 5:21 PM");
|
||||
assert.dom(".relative-time", to).hasText("10:22 PM (Singapore)");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
@ -73,14 +67,8 @@ module("Unit | discourse-local-dates", function (hooks) {
|
|||
discourse_local_dates_enabled: true,
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
from.querySelector(".relative-time").textContent,
|
||||
"Yesterday 5:21 PM"
|
||||
);
|
||||
assert.equal(
|
||||
to.querySelector(".relative-time").textContent,
|
||||
"Yesterday"
|
||||
);
|
||||
assert.dom(".relative-time", from).hasText("Yesterday 5:21 PM");
|
||||
assert.dom(".relative-time", to).hasText("Yesterday");
|
||||
}
|
||||
);
|
||||
});
|
||||
|
|
Loading…
Reference in New Issue
Block a user