mirror of
https://github.com/discourse/discourse.git
synced 2025-05-31 12:27:16 +08:00
DEV: Fix no-loose-assertions lint (#29965)
and enable some of qunit lints
This commit is contained in:
@ -44,70 +44,70 @@ module("Discourse Chat | Unit | chat-audio", function (hooks) {
|
||||
});
|
||||
});
|
||||
|
||||
test("it registers desktop notification handler", function (assert) {
|
||||
assert.ok(this.stub.calledOnce);
|
||||
test("registers desktop notification handler", function (assert) {
|
||||
assert.true(this.stub.calledOnce);
|
||||
});
|
||||
|
||||
test("it plays chat sound", async function (assert) {
|
||||
test("plays chat sound", async function (assert) {
|
||||
await this.handleNotification();
|
||||
|
||||
assert.ok(this.playStub.calledOnce);
|
||||
assert.true(this.playStub.calledOnce);
|
||||
});
|
||||
|
||||
test("it skips chat sound for user in DND mode", async function (assert) {
|
||||
test("skips chat sound for user in DND mode", async function (assert) {
|
||||
this.currentUser.isInDoNotDisturb = () => true;
|
||||
await this.handleNotification();
|
||||
|
||||
assert.ok(this.playStub.notCalled);
|
||||
assert.true(this.playStub.notCalled);
|
||||
});
|
||||
|
||||
test("it skips chat sound for user with no chat sound set", async function (assert) {
|
||||
test("skips chat sound for user with no chat sound set", async function (assert) {
|
||||
this.currentUser.chat_sound = null;
|
||||
await this.handleNotification();
|
||||
|
||||
assert.ok(this.playStub.notCalled);
|
||||
assert.true(this.playStub.notCalled);
|
||||
});
|
||||
|
||||
test("it plays a chat sound for mentions", async function (assert) {
|
||||
test("plays a chat sound for mentions", async function (assert) {
|
||||
this.currentUser.user_option.chat_header_indicator_preference =
|
||||
"only_mentions";
|
||||
|
||||
await this.handleNotification({ notification_type: 29 });
|
||||
|
||||
assert.ok(this.playStub.calledOnce);
|
||||
assert.true(this.playStub.calledOnce);
|
||||
});
|
||||
|
||||
test("it skips chat sound for non-mentions", async function (assert) {
|
||||
test("skips chat sound for non-mentions", async function (assert) {
|
||||
this.currentUser.user_option.chat_header_indicator_preference =
|
||||
"only_mentions";
|
||||
|
||||
await this.handleNotification();
|
||||
|
||||
assert.ok(this.playStub.notCalled);
|
||||
assert.true(this.playStub.notCalled);
|
||||
});
|
||||
|
||||
test("it plays a chat sound for DMs", async function (assert) {
|
||||
test("plays a chat sound for DMs", async function (assert) {
|
||||
this.currentUser.user_option.chat_header_indicator_preference =
|
||||
"dm_and_mentions";
|
||||
|
||||
await this.handleNotification({ is_direct_message_channel: true });
|
||||
|
||||
assert.ok(this.playStub.calledOnce);
|
||||
assert.true(this.playStub.calledOnce);
|
||||
});
|
||||
|
||||
test("it skips chat sound for non-DM messages", async function (assert) {
|
||||
test("skips chat sound for non-DM messages", async function (assert) {
|
||||
this.currentUser.user_option.chat_header_indicator_preference =
|
||||
"dm_and_mentions";
|
||||
|
||||
await this.handleNotification({ is_direct_message_channel: false });
|
||||
|
||||
assert.ok(this.playStub.notCalled);
|
||||
assert.true(this.playStub.notCalled);
|
||||
});
|
||||
|
||||
test("it skips chat sound when service worker returns false", async function (assert) {
|
||||
test("skips chat sound when service worker returns false", async function (assert) {
|
||||
chatAudioInitializer.canPlaySound.returns(Promise.resolve(false));
|
||||
await this.handleNotification();
|
||||
|
||||
assert.ok(this.playStub.notCalled);
|
||||
assert.true(this.playStub.notCalled);
|
||||
});
|
||||
});
|
||||
|
@ -50,8 +50,10 @@ module(
|
||||
test("open", async function (assert) {
|
||||
this.manager.open({ context: "chat-composer" });
|
||||
|
||||
assert.ok(this.manager.loading);
|
||||
assert.ok(this.manager.picker);
|
||||
assert.true(this.manager.loading);
|
||||
assert.deepEqual(this.manager.picker, {
|
||||
context: "chat-composer",
|
||||
});
|
||||
assert.strictEqual(this.manager.picker.context, "chat-composer");
|
||||
assert.deepEqual(this.manager.visibleSections, [
|
||||
"favorites",
|
||||
@ -91,14 +93,18 @@ module(
|
||||
test("close", async function (assert) {
|
||||
this.manager.open({ context: "channel-composer" });
|
||||
|
||||
assert.ok(this.manager.picker);
|
||||
assert.deepEqual(this.manager.picker, {
|
||||
context: "channel-composer",
|
||||
});
|
||||
|
||||
this.manager.addVisibleSections("objects");
|
||||
this.manager.lastVisibleSection = "objects";
|
||||
this.manager.close();
|
||||
|
||||
assert.ok(this.manager.closing);
|
||||
assert.ok(this.manager.picker);
|
||||
assert.true(this.manager.closing);
|
||||
assert.deepEqual(this.manager.picker, {
|
||||
context: "channel-composer",
|
||||
});
|
||||
|
||||
await settled();
|
||||
|
||||
|
@ -52,7 +52,7 @@ acceptance("Discourse Chat | Unit | Service | chat-guardian", function (needs) {
|
||||
set(this.currentUser, "has_chat_enabled", true);
|
||||
set(this.currentUser, "admin", true);
|
||||
this.siteSettings.chat_enabled = true;
|
||||
assert.ok(this.chatGuardian.canEditChatChannel());
|
||||
assert.true(this.chatGuardian.canEditChatChannel());
|
||||
});
|
||||
|
||||
test("#canUseChat", async function (assert) {
|
||||
@ -66,7 +66,7 @@ acceptance("Discourse Chat | Unit | Service | chat-guardian", function (needs) {
|
||||
|
||||
set(this.currentUser, "has_chat_enabled", true);
|
||||
this.siteSettings.chat_enabled = true;
|
||||
assert.ok(this.chatGuardian.canUseChat());
|
||||
assert.true(this.chatGuardian.canUseChat());
|
||||
});
|
||||
|
||||
test("#canArchiveChannel", async function (assert) {
|
||||
@ -76,7 +76,7 @@ acceptance("Discourse Chat | Unit | Service | chat-guardian", function (needs) {
|
||||
set(this.currentUser, "admin", true);
|
||||
this.siteSettings.chat_enabled = true;
|
||||
this.siteSettings.chat_allow_archiving_channels = true;
|
||||
assert.ok(this.chatGuardian.canArchiveChannel(channel));
|
||||
assert.true(this.chatGuardian.canArchiveChannel(channel));
|
||||
|
||||
set(this.currentUser, "admin", false);
|
||||
set(this.currentUser, "moderator", false);
|
||||
|
@ -26,7 +26,7 @@ module(
|
||||
|
||||
this.subject.prefersFullPage();
|
||||
|
||||
assert.ok(this.subject.isFullPagePreferred);
|
||||
assert.true(this.subject.isFullPagePreferred);
|
||||
|
||||
this.subject.prefersDrawer();
|
||||
|
||||
@ -35,11 +35,11 @@ module(
|
||||
this.subject.prefersDrawer();
|
||||
Site.currentProp("mobileView", true);
|
||||
|
||||
assert.ok(this.subject.isFullPagePreferred);
|
||||
assert.true(this.subject.isFullPagePreferred);
|
||||
});
|
||||
|
||||
test("isDrawerPreferred", function (assert) {
|
||||
assert.ok(this.subject.isDrawerPreferred);
|
||||
assert.true(this.subject.isDrawerPreferred);
|
||||
|
||||
this.subject.prefersFullPage();
|
||||
|
||||
@ -47,7 +47,7 @@ module(
|
||||
|
||||
this.subject.prefersDrawer();
|
||||
|
||||
assert.ok(this.subject.isDrawerPreferred);
|
||||
assert.true(this.subject.isDrawerPreferred);
|
||||
});
|
||||
|
||||
test("lastKnownChatURL", function (assert) {
|
||||
@ -76,7 +76,7 @@ module(
|
||||
assert.false(this.subject.isFullPageActive);
|
||||
|
||||
sinon.stub(this.subject.router, "currentRouteName").value("chat");
|
||||
assert.ok(this.subject.isFullPageActive);
|
||||
assert.true(this.subject.isFullPageActive);
|
||||
});
|
||||
|
||||
test("didCollapseDrawer", function (assert) {
|
||||
|
@ -55,7 +55,7 @@ module("Chat | Unit | Utility | plugin-api", function (hooks) {
|
||||
|
||||
// assert that the initial secondary actions are present
|
||||
const secondaryActions = interactor.secondaryActions;
|
||||
assert.ok(secondaryActions.length > 0);
|
||||
assert.true(secondaryActions.length > 0);
|
||||
|
||||
try {
|
||||
// remove the first secondary action listed
|
||||
@ -64,7 +64,7 @@ module("Chat | Unit | Utility | plugin-api", function (hooks) {
|
||||
const updatedSecondaryActions = interactor.secondaryActions;
|
||||
|
||||
// assert that the secondary action was removed
|
||||
assert.ok(
|
||||
assert.true(
|
||||
updatedSecondaryActions.length < secondaryActions.length,
|
||||
"the updated secondary actions must contain less items than the original"
|
||||
);
|
||||
|
Reference in New Issue
Block a user