DEV: Deprecate `assert.not()` (#15595)

Use QUnit's standard `assert.notOk()` instead.
This commit is contained in:
Jarek Radosz 2022-02-09 18:49:05 +01:00 committed by GitHub
parent 1f30bacb65
commit 45572f9431
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 90 additions and 73 deletions

View File

@ -183,7 +183,7 @@ acceptance("Bookmarking", function (needs) {
exists(".topic-post:first-child button.bookmark.bookmarked"),
"it shows the bookmarked icon on the post"
);
assert.not(
assert.notOk(
exists(
".topic-post:first-child button.bookmark.bookmarked > .d-icon-discourse-bookmark-clock"
),
@ -215,7 +215,7 @@ acceptance("Bookmarking", function (needs) {
await click(".bootbox.modal .btn-primary");
assert.not(
assert.notOk(
exists(".topic-post:first-child button.bookmark.bookmarked"),
"it no longer shows the bookmarked icon on the post after bookmark is deleted"
);
@ -225,7 +225,7 @@ acceptance("Bookmarking", function (needs) {
await visit("/t/internationalization-localization/280");
await openBookmarkModal();
await click(".d-modal-cancel");
assert.not(
assert.notOk(
exists(".topic-post:first-child button.bookmark.bookmarked"),
"it does not show the bookmarked icon on the post because it is not saved"
);

View File

@ -52,7 +52,10 @@ acceptance("Create Account - external auth", function (needs) {
"it shows the registration modal"
);
assert.not(exists("#new-account-username"), "it does not show the fields");
assert.notOk(
exists("#new-account-username"),
"it does not show the fields"
);
});
});

View File

@ -119,7 +119,7 @@ acceptance("Invite accept", function (needs) {
);
await fillIn("#new-account-email", "john.doe@example.com");
assert.not(
assert.notOk(
exists(".invites-show .btn-primary:disabled"),
"submit is enabled"
);
@ -151,7 +151,7 @@ acceptance("Invite accept", function (needs) {
assert.ok(exists(".username-input .good"), "username is valid");
assert.ok(exists(".password-input .good"), "password is valid");
assert.ok(exists(".email-input .good"), "email is valid");
assert.not(
assert.notOk(
exists(".invites-show .btn-primary:disabled"),
"submit is enabled"
);

View File

@ -67,7 +67,7 @@ acceptance("Accept Invite - User Fields", function (needs) {
);
await click(".user-field input[type=checkbox]");
assert.not(
assert.notOk(
exists(".invites-show .btn-primary:disabled"),
"submit is enabled because field is checked"
);

View File

@ -214,7 +214,7 @@ acceptance("Search - Full Page", function (needs) {
await fillIn(".search-query", "none in:titleasd");
assert.not(
assert.notOk(
exists(".search-advanced-options .in-title:checked"),
"does not populate title only checkbox"
);
@ -254,7 +254,7 @@ acceptance("Search - Full Page", function (needs) {
await fillIn(".search-query", "none in:personal-direct");
assert.not(
assert.notOk(
exists(".search-advanced-options .in-private:checked"),
"does not populate messages checkbox"
);
@ -278,7 +278,7 @@ acceptance("Search - Full Page", function (needs) {
await fillIn(".search-query", "none in:seenasdan");
assert.not(
assert.notOk(
exists(".search-advanced-options .in-seen:checked"),
"does not populate seen checkbox"
);
@ -446,7 +446,7 @@ acceptance("Search - Full Page", function (needs) {
await fillIn(".search-query", "in:likesasdas");
assert.not(
assert.notOk(
exists(".search-advanced-options .in-likes:checked"),
"does not populate the likes checkbox"
);

View File

@ -18,7 +18,7 @@ acceptance("Signing In", function () {
await fillIn("#login-account-password", "incorrect");
await click(".modal-footer .btn-primary");
assert.ok(exists("#modal-alert:visible"), "it displays the login error");
assert.not(
assert.notOk(
exists(".modal-footer .btn-primary:disabled"),
"enables the login button"
);
@ -91,7 +91,7 @@ acceptance("Signing In", function () {
await fillIn("#login-account-password", "need-second-factor");
await click(".modal-footer .btn-primary");
assert.not(
assert.notOk(
exists("#credentials:visible"),
"it hides the username and password prompt"
);
@ -99,7 +99,7 @@ acceptance("Signing In", function () {
exists("#second-factor:visible"),
"it displays the second factor prompt"
);
assert.not(
assert.notOk(
exists(".modal-footer .btn-primary:disabled"),
"enables the login button"
);
@ -123,11 +123,11 @@ acceptance("Signing In", function () {
await fillIn("#login-account-password", "need-security-key");
await click(".modal-footer .btn-primary");
assert.not(
assert.notOk(
exists("#credentials:visible"),
"it hides the username and password prompt"
);
assert.not(
assert.notOk(
exists("#login-second-factor:visible"),
"it does not display the second factor prompt"
);
@ -135,7 +135,7 @@ acceptance("Signing In", function () {
exists("#security-key:visible"),
"it shows the security key prompt"
);
assert.not(exists("#login-button:visible"), "hides the login button");
assert.notOk(exists("#login-button:visible"), "hides the login button");
});
test("create account", async function (assert) {

View File

@ -63,7 +63,7 @@ acceptance("Topic move posts", function (needs) {
"it opens move to modal"
);
assert.not(
assert.notOk(
queryAll(".choose-topic-modal .radios")
.html()
.includes(I18n.t("topic.split_topic.radio_label")),
@ -77,7 +77,7 @@ acceptance("Topic move posts", function (needs) {
"it shows an option to move to existing topic"
);
assert.not(
assert.notOk(
queryAll(".choose-topic-modal .radios")
.html()
.includes(I18n.t("topic.move_to_new_message.radio_label")),

View File

@ -16,7 +16,7 @@ acceptance("User's bookmarks", function (needs) {
await dropdown.expand();
await dropdown.selectRowByValue("remove");
assert.not(exists(".bootbox.modal"), "it should not show the modal");
assert.notOk(exists(".bootbox.modal"), "it should not show the modal");
});
test("it renders search controls if there are bookmarks", async function (assert) {
@ -46,7 +46,7 @@ acceptance("User's bookmarks - reminder", function (needs) {
assert.ok(exists(".bootbox.modal"), "it asks for delete confirmation");
await click(".bootbox.modal a.btn-primary");
assert.not(exists(".bootbox.modal"));
assert.notOk(exists(".bootbox.modal"));
});
});

View File

@ -20,7 +20,7 @@ acceptance("User Card - Show Local Time", function (needs) {
await visit("/t/internationalization-localization/280");
await click('a[data-user-card="charlie"]');
assert.not(
assert.notOk(
exists(".user-card .local-time"),
"it does not show the local time if the user card returns a null/undefined timezone for another user"
);

View File

@ -403,6 +403,11 @@ export function fixture(selector) {
}
QUnit.assert.not = function (actual, message) {
deprecated("assert.not() is deprecated. Use assert.notOk() instead.", {
since: "2.9.0.beta1",
dropFrom: "2.10.0.beta1",
});
this.pushResult({
result: !actual,
actual,

View File

@ -51,7 +51,10 @@ discourseModule("Unit | Controller | admin-user-badges", function () {
return badge.name;
});
assert.not(badgeNames.includes(badgeDisabled), "excludes disabled badges");
assert.notOk(
badgeNames.includes(badgeDisabled),
"excludes disabled badges"
);
assert.deepEqual(badgeNames, sortedNames, "sorts badges by name");
});
});

View File

@ -33,12 +33,15 @@ discourseModule("Unit | Controller | topic", function (hooks) {
test("editTopic", function (assert) {
const model = Topic.create();
const controller = this.getController("topic", { model });
assert.not(controller.get("editingTopic"), "we are not editing by default");
assert.notOk(
controller.get("editingTopic"),
"we are not editing by default"
);
controller.set("model.details.can_edit", false);
controller.send("editTopic");
assert.not(
assert.notOk(
controller.get("editingTopic"),
"calling editTopic doesn't enable editing unless the user can edit"
);
@ -58,7 +61,7 @@ discourseModule("Unit | Controller | topic", function (hooks) {
controller.send("cancelEditingTopic");
assert.not(
assert.notOk(
controller.get("editingTopic"),
"cancelling edit mode reverts the property value"
);
@ -84,7 +87,7 @@ discourseModule("Unit | Controller | topic", function (hooks) {
model.set("views", 10000);
controller.send("deleteTopic");
assert.not(destroyed, "don't destroy popular topic");
assert.notOk(destroyed, "don't destroy popular topic");
assert.ok(modalDisplayed, "display confirmation modal for popular topic");
model.set("views", 3);
@ -96,7 +99,7 @@ discourseModule("Unit | Controller | topic", function (hooks) {
const model = Topic.create();
const controller = this.getController("topic", { model });
assert.not(
assert.notOk(
controller.get("multiSelect"),
"multi selection mode is disabled by default"
);
@ -123,7 +126,7 @@ discourseModule("Unit | Controller | topic", function (hooks) {
controller.send("toggleMultiSelect");
await settled();
assert.not(
assert.notOk(
controller.get("multiSelect"),
"calling 'toggleMultiSelect' twice disables multi selection mode"
);
@ -145,7 +148,7 @@ discourseModule("Unit | Controller | topic", function (hooks) {
2,
"selectedPosts only contains already loaded posts"
);
assert.not(
assert.notOk(
controller.get("selectedPosts").some((p) => p === undefined),
"selectedPosts only contains valid post objects"
);
@ -157,7 +160,7 @@ discourseModule("Unit | Controller | topic", function (hooks) {
controller.set("selectedPostIds", [1, 2]);
assert.not(
assert.notOk(
controller.get("selectedAllPosts"),
"not all posts are selected"
);
@ -240,11 +243,14 @@ discourseModule("Unit | Controller | topic", function (hooks) {
const model = Topic.create({ posts_count: 3 });
const controller = this.getController("topic", { model, site });
assert.not(controller.get("showSelectedPostsAtBottom"), "false on desktop");
assert.notOk(
controller.get("showSelectedPostsAtBottom"),
"false on desktop"
);
site.set("mobileView", true);
assert.not(
assert.notOk(
controller.get("showSelectedPostsAtBottom"),
"requires at least 3 posts on mobile"
);
@ -277,14 +283,14 @@ discourseModule("Unit | Controller | topic", function (hooks) {
});
const selectedPostIds = controller.get("selectedPostIds");
assert.not(
assert.notOk(
controller.get("canDeleteSelected"),
"false when no posts are selected"
);
selectedPostIds.pushObject(1);
assert.not(
assert.notOk(
controller.get("canDeleteSelected"),
"false when can't delete one of the selected posts"
);
@ -298,7 +304,7 @@ discourseModule("Unit | Controller | topic", function (hooks) {
selectedPostIds.pushObject(1);
assert.not(
assert.notOk(
controller.get("canDeleteSelected"),
"false when all posts are selected and user is staff"
);
@ -324,14 +330,14 @@ discourseModule("Unit | Controller | topic", function (hooks) {
const controller = this.getController("topic", { model });
const selectedPostIds = controller.get("selectedPostIds");
assert.not(
assert.notOk(
controller.get("canMergeTopic"),
"can't merge topic when no posts are selected"
);
selectedPostIds.pushObject(1);
assert.not(
assert.notOk(
controller.get("canMergeTopic"),
"can't merge topic when can't move posts"
);
@ -377,14 +383,14 @@ discourseModule("Unit | Controller | topic", function (hooks) {
});
const selectedPostIds = controller.get("selectedPostIds");
assert.not(
assert.notOk(
controller.get("canChangeOwner"),
"false when no posts are selected"
);
selectedPostIds.pushObject(1);
assert.not(controller.get("canChangeOwner"), "false when not admin");
assert.notOk(controller.get("canChangeOwner"), "false when not admin");
currentUser.set("admin", true);
@ -395,7 +401,7 @@ discourseModule("Unit | Controller | topic", function (hooks) {
selectedPostIds.pushObject(2);
assert.not(
assert.notOk(
controller.get("canChangeOwner"),
"false when admin but more than 1 user"
);
@ -416,28 +422,28 @@ discourseModule("Unit | Controller | topic", function (hooks) {
});
const selectedPostIds = controller.get("selectedPostIds");
assert.not(
assert.notOk(
controller.get("canMergePosts"),
"false when no posts are selected"
);
selectedPostIds.pushObject(1);
assert.not(
assert.notOk(
controller.get("canMergePosts"),
"false when only one post is selected"
);
selectedPostIds.pushObject(2);
assert.not(
assert.notOk(
controller.get("canMergePosts"),
"false when selected posts are from different users"
);
selectedPostIds.replace(1, 1, [3]);
assert.not(
assert.notOk(
controller.get("canMergePosts"),
"false when selected posts can't be deleted"
);

View File

@ -108,7 +108,7 @@ module("Unit | Lib | timeframes-builder", function (hooks) {
this.clock = fakeTime("2100-04-19 18:00:00", timezone, true); // Monday evening
const timeframes = buildTimeframes(buildOptions(moment())).mapBy("id");
assert.not(timeframes.includes("later_today"));
assert.notOk(timeframes.includes("later_today"));
assert.ok(timeframes.includes("later_this_week"));
});
@ -117,7 +117,7 @@ module("Unit | Lib | timeframes-builder", function (hooks) {
this.clock = fakeTime("2100-04-22 18:00:00", timezone, true); // Tuesday evening
const timeframes = buildTimeframes(buildOptions(moment())).mapBy("id");
assert.not(timeframes.includes("later_this_week"));
assert.notOk(timeframes.includes("later_this_week"));
});
test("doesn't output 'Later This Week' on Sundays", function (assert) {
@ -138,7 +138,7 @@ module("Unit | Lib | timeframes-builder", function (hooks) {
this.clock = fakeTime("2100-04-25 18:00:00", timezone, true); // Sunday evening
const timeframes = buildTimeframes(buildOptions(moment())).mapBy("id");
assert.not(timeframes.includes("later_this_week"));
assert.notOk(timeframes.includes("later_this_week"));
});
test("doesn't output 'Next Month' on the last day of the month", function (assert) {
@ -146,6 +146,6 @@ module("Unit | Lib | timeframes-builder", function (hooks) {
this.clock = fakeTime("2100-04-30 18:00:00", timezone, true); // The last day of April
const timeframes = buildTimeframes(buildOptions(moment())).mapBy("id");
assert.not(timeframes.includes("next_month"));
assert.notOk(timeframes.includes("next_month"));
});
});

View File

@ -17,15 +17,15 @@ import { test } from "qunit";
discourseModule("Unit | Utility | uploads", function () {
test("validateUploadedFiles", function (assert) {
assert.not(
assert.notOk(
validateUploadedFiles(null, { siteSettings: this.siteSettings }),
"no files are invalid"
);
assert.not(
assert.notOk(
validateUploadedFiles(undefined, { siteSettings: this.siteSettings }),
"undefined files are invalid"
);
assert.not(
assert.notOk(
validateUploadedFiles([], { siteSettings: this.siteSettings }),
"empty array of files is invalid"
);
@ -34,7 +34,7 @@ discourseModule("Unit | Utility | uploads", function () {
test("uploading one file", function (assert) {
sinon.stub(bootbox, "alert");
assert.not(
assert.notOk(
validateUploadedFiles([1, 2], { siteSettings: this.siteSettings })
);
assert.ok(bootbox.alert.calledWith(I18n.t("post.errors.too_many_uploads")));
@ -44,7 +44,7 @@ discourseModule("Unit | Utility | uploads", function () {
this.siteSettings.newuser_max_embedded_media = 0;
sinon.stub(bootbox, "alert");
assert.not(
assert.notOk(
validateUploadedFiles([{ name: "image.png" }], {
user: User.create(),
siteSettings: this.siteSettings,
@ -88,7 +88,7 @@ discourseModule("Unit | Utility | uploads", function () {
this.siteSettings.newuser_max_attachments = 0;
sinon.stub(bootbox, "alert");
assert.not(
assert.notOk(
validateUploadedFiles([{ name: "roman.txt" }], {
user: User.create(),
siteSettings: this.siteSettings,
@ -103,7 +103,7 @@ discourseModule("Unit | Utility | uploads", function () {
test("ensures an authorized upload", function (assert) {
sinon.stub(bootbox, "alert");
assert.not(
assert.notOk(
validateUploadedFiles([{ name: "unauthorized.html" }], {
siteSettings: this.siteSettings,
})
@ -124,7 +124,7 @@ discourseModule("Unit | Utility | uploads", function () {
const files = [{ name: "backup.tar.gz" }];
sinon.stub(bootbox, "alert");
assert.not(
assert.notOk(
validateUploadedFiles(files, {
skipValidation: false,
siteSettings: this.siteSettings,
@ -144,7 +144,7 @@ discourseModule("Unit | Utility | uploads", function () {
sinon.stub(bootbox, "alert");
let user = User.create({ moderator: true });
assert.not(
assert.notOk(
validateUploadedFiles(files, { user, siteSettings: this.siteSettings })
);
assert.ok(
@ -193,7 +193,7 @@ discourseModule("Unit | Utility | uploads", function () {
})
);
assert.not(bootbox.alert.calledOnce);
assert.notOk(bootbox.alert.calledOnce);
});
test("isImage", function (assert) {
@ -205,9 +205,9 @@ discourseModule("Unit | Utility | uploads", function () {
image + " is recognized as an image"
);
});
assert.not(isImage("file.txt"));
assert.not(isImage("http://foo.bar/path/to/file.txt"));
assert.not(isImage(""));
assert.notOk(isImage("file.txt"));
assert.notOk(isImage("http://foo.bar/path/to/file.txt"));
assert.notOk(isImage(""));
});
test("allowsImages", function (assert) {
@ -235,7 +235,7 @@ discourseModule("Unit | Utility | uploads", function () {
test("allowsAttachments", function (assert) {
this.siteSettings.authorized_extensions = "jpg|jpeg|gif";
assert.not(
assert.notOk(
allowsAttachments(false, this.siteSettings),
"no attachments allowed by default"
);

View File

@ -13,7 +13,7 @@ module("Unit | Utility | url", function () {
test("isInternal with a HTTP url", function (assert) {
sinon.stub(DiscourseURL, "origin").returns("http://eviltrout.com");
assert.not(DiscourseURL.isInternal(null), "a blank URL is not internal");
assert.notOk(DiscourseURL.isInternal(null), "a blank URL is not internal");
assert.ok(DiscourseURL.isInternal("/test"), "relative URLs are internal");
assert.ok(
DiscourseURL.isInternal("//eviltrout.com"),
@ -27,11 +27,11 @@ module("Unit | Utility | url", function () {
DiscourseURL.isInternal("https://eviltrout.com/moustache"),
"a url on a HTTPS of the same host is internal"
);
assert.not(
assert.notOk(
DiscourseURL.isInternal("//twitter.com.com"),
"a different host is not internal (protocol-less)"
);
assert.not(
assert.notOk(
DiscourseURL.isInternal("http://twitter.com"),
"a different host is not internal"
);
@ -47,11 +47,11 @@ module("Unit | Utility | url", function () {
test("isInternal on subfolder install", function (assert) {
sinon.stub(DiscourseURL, "origin").returns("http://eviltrout.com/forum");
assert.not(
assert.notOk(
DiscourseURL.isInternal("http://eviltrout.com"),
"the host root is not internal"
);
assert.not(
assert.notOk(
DiscourseURL.isInternal("http://eviltrout.com/tophat"),
"a url on the same host but on a different folder is not internal"
);

View File

@ -60,11 +60,11 @@ module("Unit | Mixin | grant-badge-controller", function (hooks) {
.get("grantableBadges")
.map((badge) => badge.name);
assert.not(
assert.notOk(
badgeNames.includes(this.badgeDisabled),
"excludes disabled badges"
);
assert.not(
assert.notOk(
badgeNames.includes(this.badgeAutomatic),
"excludes automatic badges"
);
@ -73,7 +73,7 @@ module("Unit | Mixin | grant-badge-controller", function (hooks) {
test("selectedBadgeGrantable", function (assert) {
this.subject.set("selectedBadgeId", this.badgeDisabled.id);
assert.not(this.subject.get("selectedBadgeGrantable"));
assert.notOk(this.subject.get("selectedBadgeGrantable"));
this.subject.set("selectedBadgeId", this.badgeFirst.id);
assert.ok(this.subject.get("selectedBadgeGrantable"));

View File

@ -20,7 +20,7 @@ discourseModule("Unit | Model | topic", function () {
last_read_post_number: 1,
});
assert.not(
assert.notOk(
topic.get("visited"),
"not visited unless we've read all the posts"
);

View File

@ -108,7 +108,7 @@ module("Unit | Model | user", function () {
undefined,
"if the user has no timezone and the user is not the current user, do NOT guess with moment"
);
assert.not(
assert.notOk(
spy.calledWith("/u/howardhamlin.json", {
type: "PUT",
dataType: "json",