DEV: apply new coding standards (#10592)
This commit is contained in:
@@ -4,10 +4,10 @@ moduleFor("controller:avatar-selector", "controller:avatar-selector", {
|
||||
beforeEach() {
|
||||
this.registry.register("router:main", mapRoutes());
|
||||
},
|
||||
needs: ["controller:modal"]
|
||||
needs: ["controller:modal"],
|
||||
});
|
||||
|
||||
QUnit.test("avatarTemplate", function(assert) {
|
||||
QUnit.test("avatarTemplate", function (assert) {
|
||||
const avatarSelectorController = this.subject();
|
||||
|
||||
avatarSelectorController.setProperties({
|
||||
@@ -15,8 +15,8 @@ QUnit.test("avatarTemplate", function(assert) {
|
||||
user: {
|
||||
system_avatar_upload_id: 1,
|
||||
gravatar_avatar_upload_id: 2,
|
||||
custom_avatar_upload_id: 3
|
||||
}
|
||||
custom_avatar_upload_id: 3,
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
|
||||
@@ -12,21 +12,21 @@ moduleFor("controller:bookmark", {
|
||||
KeyboardShortcutInitializer.initialize(this.container);
|
||||
BookmarkController = this.subject({
|
||||
currentUser: User.current(),
|
||||
site: { isMobileDevice: false }
|
||||
site: { isMobileDevice: false },
|
||||
});
|
||||
BookmarkController.onShow();
|
||||
},
|
||||
|
||||
afterEach() {
|
||||
sandbox.restore();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
function mockMomentTz(dateString) {
|
||||
fakeTime(dateString, BookmarkController.userTimezone);
|
||||
}
|
||||
|
||||
QUnit.test("showLaterToday when later today is tomorrow do not show", function(
|
||||
QUnit.test("showLaterToday when later today is tomorrow do not show", function (
|
||||
assert
|
||||
) {
|
||||
mockMomentTz("2019-12-11T22:00:00");
|
||||
@@ -36,13 +36,13 @@ QUnit.test("showLaterToday when later today is tomorrow do not show", function(
|
||||
|
||||
QUnit.test(
|
||||
"showLaterToday when later today is after 5pm but before 6pm",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
mockMomentTz("2019-12-11T15:00:00");
|
||||
assert.equal(BookmarkController.get("showLaterToday"), true);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("showLaterToday when now is after the cutoff time (5pm)", function(
|
||||
QUnit.test("showLaterToday when now is after the cutoff time (5pm)", function (
|
||||
assert
|
||||
) {
|
||||
mockMomentTz("2019-12-11T17:00:00");
|
||||
@@ -51,14 +51,14 @@ QUnit.test("showLaterToday when now is after the cutoff time (5pm)", function(
|
||||
|
||||
QUnit.test(
|
||||
"showLaterToday when later today is before the end of the day, show",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
mockMomentTz("2019-12-11T10:00:00");
|
||||
|
||||
assert.equal(BookmarkController.get("showLaterToday"), true);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("nextWeek gets next week correctly", function(assert) {
|
||||
QUnit.test("nextWeek gets next week correctly", function (assert) {
|
||||
mockMomentTz("2019-12-11T08:00:00");
|
||||
|
||||
assert.equal(
|
||||
@@ -67,7 +67,7 @@ QUnit.test("nextWeek gets next week correctly", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("nextMonth gets next month correctly", function(assert) {
|
||||
QUnit.test("nextMonth gets next month correctly", function (assert) {
|
||||
mockMomentTz("2019-12-11T08:00:00");
|
||||
|
||||
assert.equal(
|
||||
@@ -76,7 +76,7 @@ QUnit.test("nextMonth gets next month correctly", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("laterThisWeek gets 2 days from now", function(assert) {
|
||||
QUnit.test("laterThisWeek gets 2 days from now", function (assert) {
|
||||
mockMomentTz("2019-12-10T08:00:00");
|
||||
|
||||
assert.equal(
|
||||
@@ -85,26 +85,27 @@ QUnit.test("laterThisWeek gets 2 days from now", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("laterThisWeek returns null if we are at Thursday already", function(
|
||||
assert
|
||||
) {
|
||||
mockMomentTz("2019-12-12T08:00:00");
|
||||
QUnit.test(
|
||||
"laterThisWeek returns null if we are at Thursday already",
|
||||
function (assert) {
|
||||
mockMomentTz("2019-12-12T08:00:00");
|
||||
|
||||
assert.equal(BookmarkController.laterThisWeek(), null);
|
||||
});
|
||||
assert.equal(BookmarkController.laterThisWeek(), null);
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("showLaterThisWeek returns true if < Thursday", function(assert) {
|
||||
QUnit.test("showLaterThisWeek returns true if < Thursday", function (assert) {
|
||||
mockMomentTz("2019-12-10T08:00:00");
|
||||
|
||||
assert.equal(BookmarkController.showLaterThisWeek, true);
|
||||
});
|
||||
|
||||
QUnit.test("showLaterThisWeek returns false if > Thursday", function(assert) {
|
||||
QUnit.test("showLaterThisWeek returns false if > Thursday", function (assert) {
|
||||
mockMomentTz("2019-12-12T08:00:00");
|
||||
|
||||
assert.equal(BookmarkController.showLaterThisWeek, false);
|
||||
});
|
||||
QUnit.test("tomorrow gets tomorrow correctly", function(assert) {
|
||||
QUnit.test("tomorrow gets tomorrow correctly", function (assert) {
|
||||
mockMomentTz("2019-12-11T08:00:00");
|
||||
|
||||
assert.equal(
|
||||
@@ -115,7 +116,7 @@ QUnit.test("tomorrow gets tomorrow correctly", function(assert) {
|
||||
|
||||
QUnit.test(
|
||||
"startOfDay changes the time of the provided date to 8:00am correctly",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
let dt = moment.tz(
|
||||
"2019-12-11T11:37:16",
|
||||
BookmarkController.currentUser.resolvedTimezone(
|
||||
@@ -132,7 +133,7 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"laterToday gets 3 hours from now and if before half-past, it rounds down",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
mockMomentTz("2019-12-11T08:13:00");
|
||||
|
||||
assert.equal(
|
||||
@@ -144,7 +145,7 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"laterToday gets 3 hours from now and if after half-past, it rounds up to the next hour",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
mockMomentTz("2019-12-11T08:43:00");
|
||||
|
||||
assert.equal(
|
||||
@@ -156,7 +157,7 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"laterToday is capped to 6pm. later today at 3pm = 6pm, 3:30pm = 6pm, 4pm = 6pm, 4:59pm = 6pm",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
mockMomentTz("2019-12-11T15:00:00");
|
||||
|
||||
assert.equal(
|
||||
@@ -191,19 +192,19 @@ QUnit.test(
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("showLaterToday returns false if >= 5PM", function(assert) {
|
||||
QUnit.test("showLaterToday returns false if >= 5PM", function (assert) {
|
||||
mockMomentTz("2019-12-11T17:00:01");
|
||||
assert.equal(BookmarkController.showLaterToday, false);
|
||||
});
|
||||
|
||||
QUnit.test("showLaterToday returns false if >= 5PM", function(assert) {
|
||||
QUnit.test("showLaterToday returns false if >= 5PM", function (assert) {
|
||||
mockMomentTz("2019-12-11T17:00:01");
|
||||
assert.equal(BookmarkController.showLaterToday, false);
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"reminderAt - custom - defaults to 8:00am if the time is not selected",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
BookmarkController.customReminderDate = "2028-12-12";
|
||||
BookmarkController.selectedReminderType =
|
||||
BookmarkController.reminderTypes.CUSTOM;
|
||||
@@ -226,7 +227,7 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"loadLastUsedCustomReminderDatetime fills the custom reminder date + time if present in localStorage",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
mockMomentTz("2019-12-11T08:00:00");
|
||||
localStorage.lastCustomBookmarkReminderDate = "2019-12-12";
|
||||
localStorage.lastCustomBookmarkReminderTime = "08:00";
|
||||
@@ -240,7 +241,7 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"loadLastUsedCustomReminderDatetime does not fills the custom reminder date + time if the datetime in localStorage is < now",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
mockMomentTz("2019-12-11T08:00:00");
|
||||
localStorage.lastCustomBookmarkReminderDate = "2019-12-11";
|
||||
localStorage.lastCustomBookmarkReminderTime = "07:00";
|
||||
@@ -252,7 +253,7 @@ QUnit.test(
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("user timezone updates when the modal is shown", function(assert) {
|
||||
QUnit.test("user timezone updates when the modal is shown", function (assert) {
|
||||
User.current().changeTimezone(null);
|
||||
let stub = sandbox.stub(moment.tz, "guess").returns("Europe/Moscow");
|
||||
BookmarkController.onShow();
|
||||
@@ -275,7 +276,7 @@ QUnit.test("user timezone updates when the modal is shown", function(assert) {
|
||||
|
||||
QUnit.test(
|
||||
"opening the modal with an existing bookmark with reminder at prefills the custom reminder type",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
let name = "test";
|
||||
let reminderAt = "2020-05-15T09:45:00";
|
||||
BookmarkController.model = { id: 1, name: name, reminderAt: reminderAt };
|
||||
|
||||
@@ -2,10 +2,10 @@ import I18n from "I18n";
|
||||
import { controllerModule } from "helpers/qunit-helpers";
|
||||
|
||||
controllerModule("controller:create-account", {
|
||||
needs: ["controller:modal", "controller:login"]
|
||||
needs: ["controller:modal", "controller:login"],
|
||||
});
|
||||
|
||||
test("basicUsernameValidation", async function(assert) {
|
||||
test("basicUsernameValidation", async function (assert) {
|
||||
const subject = this.subject;
|
||||
|
||||
const testInvalidUsername = async (username, expectedReason) => {
|
||||
@@ -34,7 +34,7 @@ test("basicUsernameValidation", async function(assert) {
|
||||
const controller = await subject();
|
||||
controller.setProperties({
|
||||
accountUsername: "porkchops",
|
||||
prefilledUsername: "porkchops"
|
||||
prefilledUsername: "porkchops",
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
@@ -49,7 +49,7 @@ test("basicUsernameValidation", async function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
test("passwordValidation", async function(assert) {
|
||||
test("passwordValidation", async function (assert) {
|
||||
const controller = await this.subject();
|
||||
|
||||
controller.set("authProvider", "");
|
||||
@@ -86,7 +86,7 @@ test("passwordValidation", async function(assert) {
|
||||
testInvalidPassword("pork@chops.com", I18n.t("user.password.same_as_email"));
|
||||
});
|
||||
|
||||
test("authProviderDisplayName", async function(assert) {
|
||||
test("authProviderDisplayName", async function (assert) {
|
||||
const controller = this.subject();
|
||||
|
||||
assert.equal(
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
moduleFor("controller:history");
|
||||
|
||||
QUnit.test("displayEdit", async function(assert) {
|
||||
QUnit.test("displayEdit", async function (assert) {
|
||||
const HistoryController = this.subject();
|
||||
|
||||
HistoryController.setProperties({
|
||||
model: { last_revision: 3, current_revision: 3, can_edit: false },
|
||||
topicController: {}
|
||||
topicController: {},
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
@@ -99,9 +99,9 @@ QUnit.test("displayEdit", async function(assert) {
|
||||
viewMode: "side_by_side",
|
||||
model: {
|
||||
body_changes: {
|
||||
side_by_side: html
|
||||
}
|
||||
}
|
||||
side_by_side: html,
|
||||
},
|
||||
},
|
||||
});
|
||||
|
||||
await HistoryController.bodyDiffChanged();
|
||||
|
||||
@@ -1,22 +1,22 @@
|
||||
import EmberObject from "@ember/object";
|
||||
moduleFor("controller:preferences/account");
|
||||
|
||||
QUnit.test("updating of associated accounts", function(assert) {
|
||||
QUnit.test("updating of associated accounts", function (assert) {
|
||||
const controller = this.subject({
|
||||
siteSettings: {
|
||||
enable_google_oauth2_logins: true
|
||||
enable_google_oauth2_logins: true,
|
||||
},
|
||||
model: EmberObject.create({
|
||||
id: 70,
|
||||
second_factor_enabled: true,
|
||||
is_anonymous: true
|
||||
is_anonymous: true,
|
||||
}),
|
||||
currentUser: EmberObject.create({
|
||||
id: 1234
|
||||
id: 1234,
|
||||
}),
|
||||
site: EmberObject.create({
|
||||
isMobileDevice: false
|
||||
})
|
||||
isMobileDevice: false,
|
||||
}),
|
||||
});
|
||||
|
||||
assert.equal(controller.get("canUpdateAssociatedAccounts"), false);
|
||||
|
||||
@@ -1,13 +1,14 @@
|
||||
moduleFor("controller:preferences/second-factor");
|
||||
|
||||
QUnit.test("displayOAuthWarning when OAuth login methods are enabled", function(
|
||||
assert
|
||||
) {
|
||||
const controller = this.subject({
|
||||
siteSettings: {
|
||||
enable_google_oauth2_logins: true
|
||||
}
|
||||
});
|
||||
QUnit.test(
|
||||
"displayOAuthWarning when OAuth login methods are enabled",
|
||||
function (assert) {
|
||||
const controller = this.subject({
|
||||
siteSettings: {
|
||||
enable_google_oauth2_logins: true,
|
||||
},
|
||||
});
|
||||
|
||||
assert.equal(controller.get("displayOAuthWarning"), true);
|
||||
});
|
||||
assert.equal(controller.get("displayOAuthWarning"), true);
|
||||
}
|
||||
);
|
||||
|
||||
@@ -6,10 +6,10 @@ moduleFor("controller:reorder-categories", "controller:reorder-categories", {
|
||||
beforeEach() {
|
||||
this.registry.register("router:main", mapRoutes());
|
||||
},
|
||||
needs: ["controller:modal"]
|
||||
needs: ["controller:modal"],
|
||||
});
|
||||
|
||||
QUnit.test("reorder set unique position number", function(assert) {
|
||||
QUnit.test("reorder set unique position number", function (assert) {
|
||||
const store = createStore();
|
||||
|
||||
const categories = [];
|
||||
@@ -31,30 +31,30 @@ QUnit.test("reorder set unique position number", function(assert) {
|
||||
|
||||
QUnit.test(
|
||||
"reorder places subcategories after their parent categories, while maintaining the relative order",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
const store = createStore();
|
||||
|
||||
const parent = store.createRecord("category", {
|
||||
id: 1,
|
||||
position: 1,
|
||||
slug: "parent"
|
||||
slug: "parent",
|
||||
});
|
||||
const child1 = store.createRecord("category", {
|
||||
id: 2,
|
||||
position: 3,
|
||||
slug: "child1",
|
||||
parent_category_id: 1
|
||||
parent_category_id: 1,
|
||||
});
|
||||
const child2 = store.createRecord("category", {
|
||||
id: 3,
|
||||
position: 0,
|
||||
slug: "child2",
|
||||
parent_category_id: 1
|
||||
parent_category_id: 1,
|
||||
});
|
||||
const other = store.createRecord("category", {
|
||||
id: 4,
|
||||
position: 2,
|
||||
slug: "other"
|
||||
slug: "other",
|
||||
});
|
||||
|
||||
const categories = [child2, parent, other, child1];
|
||||
@@ -74,25 +74,25 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"changing the position number of a category should place it at given position",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
const store = createStore();
|
||||
|
||||
const elem1 = store.createRecord("category", {
|
||||
id: 1,
|
||||
position: 0,
|
||||
slug: "foo"
|
||||
slug: "foo",
|
||||
});
|
||||
|
||||
const elem2 = store.createRecord("category", {
|
||||
id: 2,
|
||||
position: 1,
|
||||
slug: "bar"
|
||||
slug: "bar",
|
||||
});
|
||||
|
||||
const elem3 = store.createRecord("category", {
|
||||
id: 3,
|
||||
position: 2,
|
||||
slug: "test"
|
||||
slug: "test",
|
||||
});
|
||||
|
||||
const categories = [elem1, elem2, elem3];
|
||||
@@ -114,32 +114,32 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"changing the position number of a category should place it at given position and respect children",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
const store = createStore();
|
||||
|
||||
const elem1 = store.createRecord("category", {
|
||||
id: 1,
|
||||
position: 0,
|
||||
slug: "foo"
|
||||
slug: "foo",
|
||||
});
|
||||
|
||||
const child1 = store.createRecord("category", {
|
||||
id: 4,
|
||||
position: 1,
|
||||
slug: "foochild",
|
||||
parent_category_id: 1
|
||||
parent_category_id: 1,
|
||||
});
|
||||
|
||||
const elem2 = store.createRecord("category", {
|
||||
id: 2,
|
||||
position: 2,
|
||||
slug: "bar"
|
||||
slug: "bar",
|
||||
});
|
||||
|
||||
const elem3 = store.createRecord("category", {
|
||||
id: 3,
|
||||
position: 3,
|
||||
slug: "test"
|
||||
slug: "test",
|
||||
});
|
||||
|
||||
const categories = [elem1, child1, elem2, elem3];
|
||||
@@ -161,39 +161,39 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"changing the position through click on arrow of a category should place it at given position and respect children",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
const store = createStore();
|
||||
|
||||
const elem1 = store.createRecord("category", {
|
||||
id: 1,
|
||||
position: 0,
|
||||
slug: "foo"
|
||||
slug: "foo",
|
||||
});
|
||||
|
||||
const child1 = store.createRecord("category", {
|
||||
id: 4,
|
||||
position: 1,
|
||||
slug: "foochild",
|
||||
parent_category_id: 1
|
||||
parent_category_id: 1,
|
||||
});
|
||||
|
||||
const child2 = store.createRecord("category", {
|
||||
id: 5,
|
||||
position: 2,
|
||||
slug: "foochildchild",
|
||||
parent_category_id: 4
|
||||
parent_category_id: 4,
|
||||
});
|
||||
|
||||
const elem2 = store.createRecord("category", {
|
||||
id: 2,
|
||||
position: 3,
|
||||
slug: "bar"
|
||||
slug: "bar",
|
||||
});
|
||||
|
||||
const elem3 = store.createRecord("category", {
|
||||
id: 3,
|
||||
position: 4,
|
||||
slug: "test"
|
||||
slug: "test",
|
||||
});
|
||||
|
||||
const categories = [elem1, child1, child2, elem2, elem3];
|
||||
|
||||
@@ -11,12 +11,12 @@ moduleFor("controller:topic", "controller:topic", {
|
||||
"controller:composer",
|
||||
"controller:application",
|
||||
"service:app-events",
|
||||
"service:document-title"
|
||||
"service:document-title",
|
||||
],
|
||||
beforeEach() {
|
||||
this.registry.register("service:screen-track", {}, { instantiate: false });
|
||||
this.registry.injection("controller", "appEvents", "service:app-events");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
function topicWithStream(streamDetails) {
|
||||
@@ -25,7 +25,7 @@ function topicWithStream(streamDetails) {
|
||||
return topic;
|
||||
}
|
||||
|
||||
QUnit.test("editTopic", function(assert) {
|
||||
QUnit.test("editTopic", function (assert) {
|
||||
const model = Topic.create();
|
||||
const controller = this.subject({ model });
|
||||
|
||||
@@ -60,7 +60,7 @@ QUnit.test("editTopic", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("toggleMultiSelect", function(assert) {
|
||||
QUnit.test("toggleMultiSelect", function (assert) {
|
||||
const model = Topic.create();
|
||||
const controller = this.subject({ model });
|
||||
|
||||
@@ -100,7 +100,7 @@ QUnit.test("toggleMultiSelect", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("selectedPosts", function(assert) {
|
||||
QUnit.test("selectedPosts", function (assert) {
|
||||
let model = topicWithStream({ posts: [{ id: 1 }, { id: 2 }, { id: 3 }] });
|
||||
const controller = this.subject({ model });
|
||||
|
||||
@@ -112,12 +112,12 @@ QUnit.test("selectedPosts", function(assert) {
|
||||
"selectedPosts only contains already loaded posts"
|
||||
);
|
||||
assert.not(
|
||||
controller.get("selectedPosts").some(p => p === undefined),
|
||||
controller.get("selectedPosts").some((p) => p === undefined),
|
||||
"selectedPosts only contains valid post objects"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("selectedAllPosts", function(assert) {
|
||||
QUnit.test("selectedAllPosts", function (assert) {
|
||||
let model = topicWithStream({ stream: [1, 2, 3] });
|
||||
const controller = this.subject({ model });
|
||||
|
||||
@@ -138,7 +138,7 @@ QUnit.test("selectedAllPosts", function(assert) {
|
||||
|
||||
model.setProperties({
|
||||
"postStream.isMegaTopic": true,
|
||||
posts_count: 1
|
||||
posts_count: 1,
|
||||
});
|
||||
|
||||
assert.ok(
|
||||
@@ -147,14 +147,14 @@ QUnit.test("selectedAllPosts", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("selectedPostsUsername", function(assert) {
|
||||
QUnit.test("selectedPostsUsername", function (assert) {
|
||||
let model = topicWithStream({
|
||||
posts: [
|
||||
{ id: 1, username: "gary" },
|
||||
{ id: 2, username: "gary" },
|
||||
{ id: 3, username: "lili" }
|
||||
{ id: 3, username: "lili" },
|
||||
],
|
||||
stream: [1, 2, 3]
|
||||
stream: [1, 2, 3],
|
||||
});
|
||||
const controller = this.subject({ model });
|
||||
const selectedPostIds = controller.get("selectedPostIds");
|
||||
@@ -198,7 +198,7 @@ QUnit.test("selectedPostsUsername", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("showSelectedPostsAtBottom", function(assert) {
|
||||
QUnit.test("showSelectedPostsAtBottom", function (assert) {
|
||||
const site = EmberObject.create({ mobileView: false });
|
||||
const model = Topic.create({ posts_count: 3 });
|
||||
const controller = this.subject({ model, site });
|
||||
@@ -220,19 +220,19 @@ QUnit.test("showSelectedPostsAtBottom", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("canDeleteSelected", function(assert) {
|
||||
QUnit.test("canDeleteSelected", function (assert) {
|
||||
const currentUser = User.create({ admin: false });
|
||||
this.registry.register("current-user:main", currentUser, {
|
||||
instantiate: false
|
||||
instantiate: false,
|
||||
});
|
||||
this.registry.injection("controller", "currentUser", "current-user:main");
|
||||
let model = topicWithStream({
|
||||
posts: [
|
||||
{ id: 1, can_delete: false },
|
||||
{ id: 2, can_delete: true },
|
||||
{ id: 3, can_delete: true }
|
||||
{ id: 3, can_delete: true },
|
||||
],
|
||||
stream: [1, 2, 3]
|
||||
stream: [1, 2, 3],
|
||||
});
|
||||
const controller = this.subject({ model });
|
||||
const selectedPostIds = controller.get("selectedPostIds");
|
||||
@@ -271,14 +271,14 @@ QUnit.test("canDeleteSelected", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Can split/merge topic", function(assert) {
|
||||
QUnit.test("Can split/merge topic", function (assert) {
|
||||
let model = topicWithStream({
|
||||
posts: [
|
||||
{ id: 1, post_number: 1, post_type: 1 },
|
||||
{ id: 2, post_number: 2, post_type: 4 },
|
||||
{ id: 3, post_number: 3, post_type: 1 }
|
||||
{ id: 3, post_number: 3, post_type: 1 },
|
||||
],
|
||||
stream: [1, 2, 3]
|
||||
stream: [1, 2, 3],
|
||||
});
|
||||
model.set("details.can_move_posts", false);
|
||||
const controller = this.subject({ model });
|
||||
@@ -316,19 +316,19 @@ QUnit.test("Can split/merge topic", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("canChangeOwner", function(assert) {
|
||||
QUnit.test("canChangeOwner", function (assert) {
|
||||
const currentUser = User.create({ admin: false });
|
||||
this.registry.register("current-user:main", currentUser, {
|
||||
instantiate: false
|
||||
instantiate: false,
|
||||
});
|
||||
this.registry.injection("controller", "currentUser", "current-user:main");
|
||||
|
||||
let model = topicWithStream({
|
||||
posts: [
|
||||
{ id: 1, username: "gary" },
|
||||
{ id: 2, username: "lili" }
|
||||
{ id: 2, username: "lili" },
|
||||
],
|
||||
stream: [1, 2]
|
||||
stream: [1, 2],
|
||||
});
|
||||
model.set("currentUser", { admin: false });
|
||||
const controller = this.subject({ model });
|
||||
@@ -358,15 +358,15 @@ QUnit.test("canChangeOwner", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("canMergePosts", function(assert) {
|
||||
QUnit.test("canMergePosts", function (assert) {
|
||||
let model = topicWithStream({
|
||||
posts: [
|
||||
{ id: 1, username: "gary", can_delete: true },
|
||||
{ id: 2, username: "lili", can_delete: true },
|
||||
{ id: 3, username: "gary", can_delete: false },
|
||||
{ id: 4, username: "gary", can_delete: true }
|
||||
{ id: 4, username: "gary", can_delete: true },
|
||||
],
|
||||
stream: [1, 2, 3]
|
||||
stream: [1, 2, 3],
|
||||
});
|
||||
const controller = this.subject({ model });
|
||||
const selectedPostIds = controller.get("selectedPostIds");
|
||||
@@ -405,7 +405,7 @@ QUnit.test("canMergePosts", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Select/deselect all", function(assert) {
|
||||
QUnit.test("Select/deselect all", function (assert) {
|
||||
let model = topicWithStream({ stream: [1, 2, 3] });
|
||||
const controller = this.subject({ model });
|
||||
|
||||
@@ -432,7 +432,7 @@ QUnit.test("Select/deselect all", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("togglePostSelection", function(assert) {
|
||||
QUnit.test("togglePostSelection", function (assert) {
|
||||
const controller = this.subject();
|
||||
const selectedPostIds = controller.get("selectedPostIds");
|
||||
|
||||
@@ -468,17 +468,17 @@ QUnit.test("togglePostSelection", function(assert) {
|
||||
// assert.equal(selectedPostIds[2], 100, "selected post #100");
|
||||
// });
|
||||
|
||||
QUnit.test("selectBelow", function(assert) {
|
||||
QUnit.test("selectBelow", function (assert) {
|
||||
const site = EmberObject.create({
|
||||
post_types: { small_action: 3, whisper: 4 }
|
||||
post_types: { small_action: 3, whisper: 4 },
|
||||
});
|
||||
let model = topicWithStream({
|
||||
stream: [1, 2, 3, 4, 5, 6, 7, 8],
|
||||
posts: [
|
||||
{ id: 5, cooked: "whisper post", post_type: 4 },
|
||||
{ id: 6, cooked: "a small action", post_type: 3 },
|
||||
{ id: 7, cooked: "", post_type: 4 }
|
||||
]
|
||||
{ id: 7, cooked: "", post_type: 4 },
|
||||
],
|
||||
});
|
||||
const controller = this.subject({ site, model });
|
||||
let selectedPostIds = controller.get("selectedPostIds");
|
||||
@@ -493,16 +493,16 @@ QUnit.test("selectBelow", function(assert) {
|
||||
assert.equal(selectedPostIds[3], 8, "also selected 3rd post below post #3");
|
||||
});
|
||||
|
||||
QUnit.test("topVisibleChanged", function(assert) {
|
||||
QUnit.test("topVisibleChanged", function (assert) {
|
||||
let model = topicWithStream({
|
||||
posts: [{ id: 1 }]
|
||||
posts: [{ id: 1 }],
|
||||
});
|
||||
const controller = this.subject({ model });
|
||||
const placeholder = new Placeholder("post-placeholder");
|
||||
|
||||
assert.equal(
|
||||
controller.send("topVisibleChanged", {
|
||||
post: placeholder
|
||||
post: placeholder,
|
||||
}),
|
||||
null,
|
||||
"it should work with a post-placehodler"
|
||||
@@ -511,7 +511,7 @@ QUnit.test("topVisibleChanged", function(assert) {
|
||||
|
||||
QUnit.test(
|
||||
"deletePost - no modal is shown if post does not have replies",
|
||||
function(assert) {
|
||||
function (assert) {
|
||||
pretender.get("/posts/2/reply-ids.json", () => {
|
||||
return [200, { "Content-Type": "application/json" }, []];
|
||||
});
|
||||
@@ -525,13 +525,13 @@ QUnit.test(
|
||||
destroy: () => {
|
||||
destroyed = true;
|
||||
return Promise.resolve();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
const currentUser = EmberObject.create({ moderator: true });
|
||||
let model = topicWithStream({
|
||||
stream: [2, 3, 4],
|
||||
posts: [post, { id: 3 }, { id: 4 }]
|
||||
posts: [post, { id: 3 }, { id: 4 }],
|
||||
});
|
||||
const controller = this.subject({ model, currentUser });
|
||||
|
||||
|
||||
Reference in New Issue
Block a user