mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
DEV: apply new coding standards (#10592)
This commit is contained in:
@@ -11,12 +11,12 @@ componentTest("default", {
|
||||
this.site.groups = [
|
||||
{
|
||||
id: 1,
|
||||
name: "Donuts"
|
||||
name: "Donuts",
|
||||
},
|
||||
{
|
||||
id: 2,
|
||||
name: "Cheese cake"
|
||||
}
|
||||
name: "Cheese cake",
|
||||
},
|
||||
];
|
||||
|
||||
this.set(
|
||||
@@ -33,7 +33,7 @@ componentTest("default", {
|
||||
setting: "foo_bar",
|
||||
type: "group_list",
|
||||
validValues: undefined,
|
||||
value: "1"
|
||||
value: "1",
|
||||
})
|
||||
);
|
||||
},
|
||||
@@ -55,5 +55,5 @@ componentTest("default", {
|
||||
"1,2",
|
||||
"it allows to select a setting from the list of choices"
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -13,7 +13,7 @@ componentTest("default theme", {
|
||||
test(assert) {
|
||||
assert.expect(1);
|
||||
assert.equal(find(".d-icon-check").length, 1, "shows default theme icon");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("pending updates", {
|
||||
@@ -28,7 +28,7 @@ componentTest("pending updates", {
|
||||
test(assert) {
|
||||
assert.expect(1);
|
||||
assert.equal(find(".d-icon-sync").length, 1, "shows pending update icon");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("broken theme", {
|
||||
@@ -38,7 +38,7 @@ componentTest("broken theme", {
|
||||
"theme",
|
||||
Theme.create({
|
||||
name: "Test",
|
||||
theme_fields: [{ name: "scss", type_id: 1, error: "something" }]
|
||||
theme_fields: [{ name: "scss", type_id: 1, error: "something" }],
|
||||
})
|
||||
);
|
||||
},
|
||||
@@ -50,14 +50,14 @@ componentTest("broken theme", {
|
||||
1,
|
||||
"shows broken theme icon"
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("with children", {
|
||||
template: "{{themes-list-item theme=theme}}",
|
||||
|
||||
beforeEach() {
|
||||
this.childrenList = [1, 2, 3, 4, 5].map(num =>
|
||||
this.childrenList = [1, 2, 3, 4, 5].map((num) =>
|
||||
Theme.create({ name: `Child ${num}`, component: true })
|
||||
);
|
||||
|
||||
@@ -66,7 +66,7 @@ componentTest("with children", {
|
||||
Theme.create({
|
||||
name: "Test",
|
||||
childThemes: this.childrenList,
|
||||
default: true
|
||||
default: true,
|
||||
})
|
||||
);
|
||||
},
|
||||
@@ -78,20 +78,18 @@ componentTest("with children", {
|
||||
.text()
|
||||
.trim()
|
||||
.split(",")
|
||||
.map(n => n.trim())
|
||||
.map((n) => n.trim())
|
||||
.join(","),
|
||||
this.childrenList
|
||||
.splice(0, 4)
|
||||
.map(theme => theme.get("name"))
|
||||
.map((theme) => theme.get("name"))
|
||||
.join(","),
|
||||
"lists the first 4 children"
|
||||
);
|
||||
assert.deepEqual(
|
||||
find(".others-count")
|
||||
.text()
|
||||
.trim(),
|
||||
find(".others-count").text().trim(),
|
||||
I18n.t("admin.customize.theme.and_x_more", { count: 1 }),
|
||||
"shows count of remaining children"
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -8,21 +8,21 @@ componentTest("current tab is themes", {
|
||||
template:
|
||||
"{{themes-list themes=themes components=components currentTab=currentTab}}",
|
||||
beforeEach() {
|
||||
this.themes = [1, 2, 3, 4, 5].map(num =>
|
||||
this.themes = [1, 2, 3, 4, 5].map((num) =>
|
||||
Theme.create({ name: `Theme ${num}` })
|
||||
);
|
||||
this.components = [1, 2, 3, 4, 5].map(num =>
|
||||
this.components = [1, 2, 3, 4, 5].map((num) =>
|
||||
Theme.create({
|
||||
name: `Child ${num}`,
|
||||
component: true,
|
||||
parentThemes: [this.themes[num - 1]],
|
||||
parent_themes: [1, 2, 3, 4, 5]
|
||||
parent_themes: [1, 2, 3, 4, 5],
|
||||
})
|
||||
);
|
||||
this.setProperties({
|
||||
themes: this.themes,
|
||||
components: this.components,
|
||||
currentTab: THEMES
|
||||
currentTab: THEMES,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -45,12 +45,12 @@ componentTest("current tab is themes", {
|
||||
);
|
||||
assert.equal(find(".themes-list-item").length, 5, "displays all themes");
|
||||
|
||||
[2, 3].forEach(num => this.themes[num].set("user_selectable", true));
|
||||
[2, 3].forEach((num) => this.themes[num].set("user_selectable", true));
|
||||
this.themes[4].set("default", true);
|
||||
this.set("themes", this.themes);
|
||||
const names = [4, 2, 3, 0, 1].map(num => this.themes[num].get("name")); // default theme always on top, followed by user-selectable ones and then the rest
|
||||
const names = [4, 2, 3, 0, 1].map((num) => this.themes[num].get("name")); // default theme always on top, followed by user-selectable ones and then the rest
|
||||
assert.deepEqual(
|
||||
Array.from(find(".themes-list-item").find(".name")).map(node =>
|
||||
Array.from(find(".themes-list-item").find(".name")).map((node) =>
|
||||
node.innerText.trim()
|
||||
),
|
||||
names,
|
||||
@@ -62,7 +62,7 @@ componentTest("current tab is themes", {
|
||||
"the separator is in the right location"
|
||||
);
|
||||
|
||||
this.themes.forEach(theme => theme.set("user_selectable", true));
|
||||
this.themes.forEach((theme) => theme.set("user_selectable", true));
|
||||
this.set("themes", this.themes);
|
||||
assert.equal(
|
||||
find(".inactive-indicator").index(),
|
||||
@@ -77,34 +77,32 @@ componentTest("current tab is themes", {
|
||||
"shows one entry with a message when there is nothing to display"
|
||||
);
|
||||
assert.equal(
|
||||
find(".themes-list-item span.empty")
|
||||
.text()
|
||||
.trim(),
|
||||
find(".themes-list-item span.empty").text().trim(),
|
||||
I18n.t("admin.customize.theme.empty"),
|
||||
"displays the right message"
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
componentTest("current tab is components", {
|
||||
template:
|
||||
"{{themes-list themes=themes components=components currentTab=currentTab}}",
|
||||
beforeEach() {
|
||||
this.themes = [1, 2, 3, 4, 5].map(num =>
|
||||
this.themes = [1, 2, 3, 4, 5].map((num) =>
|
||||
Theme.create({ name: `Theme ${num}` })
|
||||
);
|
||||
this.components = [1, 2, 3, 4, 5].map(num =>
|
||||
this.components = [1, 2, 3, 4, 5].map((num) =>
|
||||
Theme.create({
|
||||
name: `Child ${num}`,
|
||||
component: true,
|
||||
parentThemes: [this.themes[num - 1]],
|
||||
parent_themes: [1, 2, 3, 4, 5]
|
||||
parent_themes: [1, 2, 3, 4, 5],
|
||||
})
|
||||
);
|
||||
this.setProperties({
|
||||
themes: this.themes,
|
||||
components: this.components,
|
||||
currentTab: COMPONENTS
|
||||
currentTab: COMPONENTS,
|
||||
});
|
||||
},
|
||||
|
||||
@@ -138,11 +136,9 @@ componentTest("current tab is components", {
|
||||
"shows one entry with a message when there is nothing to display"
|
||||
);
|
||||
assert.equal(
|
||||
find(".themes-list-item span.empty")
|
||||
.text()
|
||||
.trim(),
|
||||
find(".themes-list-item span.empty").text().trim(),
|
||||
I18n.t("admin.customize.theme.empty"),
|
||||
"displays the right message"
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -5,21 +5,21 @@ moduleFor("controller:admin-customize-themes-show", {
|
||||
beforeEach() {
|
||||
this.registry.register("router:main", mapRoutes());
|
||||
},
|
||||
needs: ["controller:adminUser"]
|
||||
needs: ["controller:adminUser"],
|
||||
});
|
||||
|
||||
QUnit.test("can display source url for remote themes", function(assert) {
|
||||
QUnit.test("can display source url for remote themes", function (assert) {
|
||||
const repoUrl = "https://github.com/discourse/discourse-brand-header.git";
|
||||
const remoteTheme = Theme.create({
|
||||
id: 2,
|
||||
default: true,
|
||||
name: "default",
|
||||
remote_theme: {
|
||||
remote_url: repoUrl
|
||||
}
|
||||
remote_url: repoUrl,
|
||||
},
|
||||
});
|
||||
const controller = this.subject({
|
||||
model: remoteTheme
|
||||
model: remoteTheme,
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
@@ -29,7 +29,7 @@ QUnit.test("can display source url for remote themes", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("can display source url for remote theme branches", function(
|
||||
QUnit.test("can display source url for remote theme branches", function (
|
||||
assert
|
||||
) {
|
||||
const remoteTheme = Theme.create({
|
||||
@@ -38,11 +38,11 @@ QUnit.test("can display source url for remote theme branches", function(
|
||||
name: "default",
|
||||
remote_theme: {
|
||||
remote_url: "https://github.com/discourse/discourse-brand-header.git",
|
||||
branch: "beta"
|
||||
}
|
||||
branch: "beta",
|
||||
},
|
||||
});
|
||||
const controller = this.subject({
|
||||
model: remoteTheme
|
||||
model: remoteTheme,
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
|
||||
@@ -5,37 +5,39 @@ moduleFor("controller:admin-customize-themes", {
|
||||
beforeEach() {
|
||||
this.registry.register("router:main", mapRoutes());
|
||||
},
|
||||
needs: ["controller:adminUser"]
|
||||
needs: ["controller:adminUser"],
|
||||
});
|
||||
|
||||
QUnit.test("can list themes correctly", function(assert) {
|
||||
QUnit.test("can list themes correctly", function (assert) {
|
||||
const defaultTheme = Theme.create({ id: 2, default: true, name: "default" });
|
||||
const userTheme = Theme.create({
|
||||
id: 3,
|
||||
user_selectable: true,
|
||||
name: "name"
|
||||
name: "name",
|
||||
});
|
||||
const strayTheme1 = Theme.create({ id: 4, name: "stray1" });
|
||||
const strayTheme2 = Theme.create({ id: 5, name: "stray2" });
|
||||
const componentTheme = Theme.create({
|
||||
id: 6,
|
||||
name: "component",
|
||||
component: true
|
||||
component: true,
|
||||
});
|
||||
|
||||
const controller = this.subject({
|
||||
model: [strayTheme2, strayTheme1, userTheme, defaultTheme, componentTheme]
|
||||
model: [strayTheme2, strayTheme1, userTheme, defaultTheme, componentTheme],
|
||||
});
|
||||
|
||||
assert.deepEqual(
|
||||
controller.get("fullThemes").map(t => t.get("name")),
|
||||
[strayTheme2, strayTheme1, userTheme, defaultTheme].map(t => t.get("name")),
|
||||
controller.get("fullThemes").map((t) => t.get("name")),
|
||||
[strayTheme2, strayTheme1, userTheme, defaultTheme].map((t) =>
|
||||
t.get("name")
|
||||
),
|
||||
"returns a list of themes without components"
|
||||
);
|
||||
|
||||
assert.deepEqual(
|
||||
controller.get("childThemes").map(t => t.get("name")),
|
||||
[componentTheme].map(t => t.get("name")),
|
||||
controller.get("childThemes").map((t) => t.get("name")),
|
||||
[componentTheme].map((t) => t.get("name")),
|
||||
"separate components from themes"
|
||||
);
|
||||
});
|
||||
|
||||
@@ -5,48 +5,48 @@ moduleFor("controller:admin-user-badges", {
|
||||
beforeEach() {
|
||||
this.registry.register("router:main", mapRoutes());
|
||||
},
|
||||
needs: ["controller:adminUser"]
|
||||
needs: ["controller:adminUser"],
|
||||
});
|
||||
|
||||
QUnit.test("grantableBadges", function(assert) {
|
||||
QUnit.test("grantableBadges", function (assert) {
|
||||
const badgeFirst = Badge.create({
|
||||
id: 3,
|
||||
name: "A Badge",
|
||||
enabled: true,
|
||||
manually_grantable: true
|
||||
manually_grantable: true,
|
||||
});
|
||||
const badgeMiddle = Badge.create({
|
||||
id: 1,
|
||||
name: "My Badge",
|
||||
enabled: true,
|
||||
manually_grantable: true
|
||||
manually_grantable: true,
|
||||
});
|
||||
const badgeLast = Badge.create({
|
||||
id: 2,
|
||||
name: "Zoo Badge",
|
||||
enabled: true,
|
||||
manually_grantable: true
|
||||
manually_grantable: true,
|
||||
});
|
||||
const badgeDisabled = Badge.create({
|
||||
id: 4,
|
||||
name: "Disabled Badge",
|
||||
enabled: false,
|
||||
manually_grantable: true
|
||||
manually_grantable: true,
|
||||
});
|
||||
const badgeAutomatic = Badge.create({
|
||||
id: 5,
|
||||
name: "Automatic Badge",
|
||||
enabled: true,
|
||||
manually_grantable: false
|
||||
manually_grantable: false,
|
||||
});
|
||||
|
||||
const controller = this.subject({
|
||||
model: [],
|
||||
badges: [badgeLast, badgeFirst, badgeMiddle, badgeDisabled, badgeAutomatic]
|
||||
badges: [badgeLast, badgeFirst, badgeMiddle, badgeDisabled, badgeAutomatic],
|
||||
});
|
||||
|
||||
const sortedNames = [badgeFirst.name, badgeMiddle.name, badgeLast.name];
|
||||
const badgeNames = controller.get("grantableBadges").map(function(badge) {
|
||||
const badgeNames = controller.get("grantableBadges").map(function (badge) {
|
||||
return badge.name;
|
||||
});
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import Theme from "admin/models/theme";
|
||||
|
||||
QUnit.module("model:theme");
|
||||
|
||||
QUnit.test("can add an upload correctly", function(assert) {
|
||||
QUnit.test("can add an upload correctly", function (assert) {
|
||||
let theme = Theme.create();
|
||||
|
||||
assert.equal(
|
||||
|
||||
Reference in New Issue
Block a user