DEV: apply new coding standards (#10592)

This commit is contained in:
Joffrey JAFFEUX
2020-09-04 13:42:47 +02:00
committed by GitHub
parent 80dfaeb0d2
commit 52672b9eab
1473 changed files with 9386 additions and 9958 deletions

View File

@@ -8,7 +8,7 @@ widgetTest("post deleted", {
this.set("args", {
deleted_at: "2016-01-01",
deletedByUsername: "eviltrout",
deletedByAvatarTemplate: "/images/avatar.png"
deletedByAvatarTemplate: "/images/avatar.png",
});
},
test(assert) {
@@ -20,5 +20,5 @@ widgetTest("post deleted", {
find(".avatar[title=eviltrout]").length === 1,
"it has the deleted by avatar"
);
}
},
});

View File

@@ -8,7 +8,7 @@ widgetTest("avatar flair with an icon", {
this.set("args", {
primary_group_flair_url: "fa-bars",
primary_group_flair_bg_color: "CC0000",
primary_group_flair_color: "FFFFFF"
primary_group_flair_color: "FFFFFF",
});
},
test(assert) {
@@ -19,18 +19,18 @@ widgetTest("avatar flair with an icon", {
"background-color: #CC0000; color: #FFFFFF; ",
"it has styles"
);
}
},
});
widgetTest("avatar flair with an image", {
template: '{{mount-widget widget="avatar-flair" args=args}}',
beforeEach() {
this.set("args", {
primary_group_flair_url: "/images/avatar.png"
primary_group_flair_url: "/images/avatar.png",
});
},
test(assert) {
assert.ok(find(".avatar-flair").length, "it has the tag");
assert.ok(find("svg").length === 0, "it does not have an svg icon");
}
},
});

View File

@@ -18,7 +18,7 @@ widgetTest("icon only button", {
find("button .d-icon.d-icon-far-smile").length,
"it has the icon"
);
}
},
});
widgetTest("icon and text button", {
@@ -35,7 +35,7 @@ widgetTest("icon and text button", {
);
assert.ok(find("button .d-icon.d-icon-plus").length, "it has the icon");
assert.ok(find("button span.d-button-label").length, "it has the label");
}
},
});
widgetTest("text only button", {
@@ -48,5 +48,5 @@ widgetTest("text only button", {
test(assert) {
assert.ok(find("button.btn.btn-text").length, "it has all the classes");
assert.ok(find("button span.d-button-label").length, "it has the label");
}
},
});

View File

@@ -25,14 +25,14 @@ widgetTest("sets notification as read on middle click", {
original_post_type: 1,
original_username: "discobot",
revision_number: null,
display_username: "discobot"
}
display_username: "discobot",
},
})
);
},
async test(assert) {
let requests = 0;
pretender.put("/notifications/mark-read", request => {
pretender.put("/notifications/mark-read", (request) => {
++requests;
assert.equal(
@@ -50,11 +50,11 @@ widgetTest("sets notification as read on middle click", {
$.Event("mouseup", {
target: find("li")[0],
button: 1,
which: 2
which: 2,
})
);
assert.equal(find("li.read").length, 1);
assert.equal(requests, 1);
}
},
});

View File

@@ -19,7 +19,7 @@ widgetTest("prioritize faq", {
test(assert) {
assert.ok(find(".faq-priority").length);
assert.ok(!find(".faq-link").length);
}
},
});
widgetTest("prioritize faq - user has read", {
@@ -33,7 +33,7 @@ widgetTest("prioritize faq - user has read", {
test(assert) {
assert.ok(!find(".faq-priority").length);
assert.ok(find(".faq-link").length);
}
},
});
widgetTest("staff menu - not staff", {
@@ -45,7 +45,7 @@ widgetTest("staff menu - not staff", {
test(assert) {
assert.ok(!find(".admin-link").length);
}
},
});
widgetTest("staff menu - moderator", {
@@ -59,7 +59,7 @@ widgetTest("staff menu - moderator", {
assert.ok(find(".admin-link").length);
assert.ok(find(".review").length);
assert.ok(!find(".settings-link").length);
}
},
});
widgetTest("staff menu - admin", {
@@ -71,7 +71,7 @@ widgetTest("staff menu - admin", {
test(assert) {
assert.ok(find(".settings-link").length);
}
},
});
widgetTest("logged in links", {
@@ -80,7 +80,7 @@ widgetTest("logged in links", {
test(assert) {
assert.ok(find(".new-topics-link").length);
assert.ok(find(".unread-topics-link").length);
}
},
});
widgetTest("general links", {
@@ -95,7 +95,7 @@ widgetTest("general links", {
assert.ok(find(".top-topics-link").length);
assert.ok(find(".badge-link").length);
assert.ok(find(".category-link").length > 0);
}
},
});
let maxCategoriesToDisplay;
@@ -115,10 +115,10 @@ widgetTest("top categories - anonymous", {
this.site
.get("categoriesByCount")
.slice(0, 8)
.map(c => c.name)
.map((c) => c.name)
.join("")
);
}
},
});
widgetTest("top categories - allow_uncategorized_topics", {
@@ -136,12 +136,12 @@ widgetTest("top categories - allow_uncategorized_topics", {
find(".category-link .category-name").text(),
this.site
.get("categoriesByCount")
.filter(c => c.name !== "uncategorized")
.filter((c) => c.name !== "uncategorized")
.slice(0, 8)
.map(c => c.name)
.map((c) => c.name)
.join("")
);
}
},
});
widgetTest("top categories", {
@@ -151,7 +151,7 @@ widgetTest("top categories", {
this.siteSettings.header_dropdown_category_count = 8;
maxCategoriesToDisplay = this.siteSettings.header_dropdown_category_count;
categoriesByCount = this.site.get("categoriesByCount").slice();
categoriesByCount.every(c => {
categoriesByCount.every((c) => {
if (!topCategoryIds.includes(c.id)) {
if (mutedCategoryIds.length === 0) {
mutedCategoryIds.push(c.id);
@@ -163,7 +163,7 @@ widgetTest("top categories", {
category_id: c.id,
last_read_post_number: 1,
highest_post_number: 2,
notification_level: NotificationLevels.TRACKING
notification_level: NotificationLevels.TRACKING,
};
}
} else {
@@ -171,7 +171,7 @@ widgetTest("top categories", {
for (let i = 0; i < 10; i++) {
c.topicTrackingState.states["t321" + i] = {
category_id: c.id,
last_read_post_number: null
last_read_post_number: null,
};
}
return false;
@@ -186,21 +186,21 @@ widgetTest("top categories", {
assert.equal(find(".category-link").length, maxCategoriesToDisplay);
categoriesByCount = categoriesByCount.filter(
c => !mutedCategoryIds.includes(c.id)
(c) => !mutedCategoryIds.includes(c.id)
);
let ids = [
...unreadCategoryIds,
...topCategoryIds,
...categoriesByCount.map(c => c.id)
...categoriesByCount.map((c) => c.id),
]
.uniq()
.slice(0, maxCategoriesToDisplay);
assert.equal(
find(".category-link .category-name").text(),
ids.map(i => categoriesByCount.find(c => c.id === i).name).join("")
ids.map((i) => categoriesByCount.find((c) => c.id === i).name).join("")
);
}
},
});
widgetTest("badges link - disabled", {
@@ -212,7 +212,7 @@ widgetTest("badges link - disabled", {
test(assert) {
assert.ok(!find(".badge-link").length);
}
},
});
widgetTest("badges link", {
@@ -220,7 +220,7 @@ widgetTest("badges link", {
test(assert) {
assert.ok(find(".badge-link").length);
}
},
});
widgetTest("user directory link", {
@@ -228,7 +228,7 @@ widgetTest("user directory link", {
test(assert) {
assert.ok(find(".user-directory-link").length);
}
},
});
widgetTest("user directory link - disabled", {
@@ -240,7 +240,7 @@ widgetTest("user directory link - disabled", {
test(assert) {
assert.ok(!find(".user-directory-link").length);
}
},
});
widgetTest("general links", {
@@ -249,5 +249,5 @@ widgetTest("general links", {
test(assert) {
assert.ok(find(".about-link").length);
assert.ok(find(".keyboard-shortcuts-link").length);
}
},
});

View File

@@ -7,7 +7,7 @@ widgetTest("rendering basics", {
test(assert) {
assert.ok(find("header.d-header").length);
assert.ok(find("#site-logo").length);
}
},
});
widgetTest("sign up / login buttons", {
@@ -30,7 +30,7 @@ widgetTest("sign up / login buttons", {
await click("button.login-button");
assert.ok(this.loginShown);
}
},
});
widgetTest("anon when login required", {
@@ -50,7 +50,7 @@ widgetTest("anon when login required", {
assert.ok(exists("button.sign-up-button"));
assert.ok(!exists("#search-button"));
assert.ok(!exists("#toggle-hamburger-menu"));
}
},
});
widgetTest("logged in when login required", {
@@ -70,5 +70,5 @@ widgetTest("logged in when login required", {
assert.ok(exists("#search-button"));
assert.ok(exists("#toggle-hamburger-menu"));
assert.ok(exists("#current-user"));
}
},
});

View File

@@ -25,7 +25,7 @@ widgetTest("basics", {
assert.ok(find("img#site-logo.logo-big").length === 1);
assert.equal(find("#site-logo").attr("src"), bigLogo);
assert.equal(find("#site-logo").attr("alt"), title);
}
},
});
widgetTest("basics - minimized", {
@@ -42,7 +42,7 @@ widgetTest("basics - minimized", {
assert.equal(find("img.logo-small").attr("src"), smallLogo);
assert.equal(find("img.logo-small").attr("alt"), title);
assert.equal(find("img.logo-small").attr("width"), 36);
}
},
});
widgetTest("no logo", {
@@ -57,7 +57,7 @@ widgetTest("no logo", {
test(assert) {
assert.ok(find("h1#site-text-logo.text-logo").length === 1);
assert.equal(find("#site-text-logo").text(), title);
}
},
});
widgetTest("no logo - minimized", {
@@ -71,7 +71,7 @@ widgetTest("no logo - minimized", {
test(assert) {
assert.ok(find(".d-icon-home").length === 1);
}
},
});
widgetTest("mobile logo", {
@@ -85,7 +85,7 @@ widgetTest("mobile logo", {
test(assert) {
assert.ok(find("img#site-logo.logo-mobile").length === 1);
assert.equal(find("#site-logo").attr("src"), mobileLogo);
}
},
});
widgetTest("mobile without logo", {
@@ -98,7 +98,7 @@ widgetTest("mobile without logo", {
test(assert) {
assert.ok(find("img#site-logo.logo-big").length === 1);
assert.equal(find("#site-logo").attr("src"), bigLogo);
}
},
});
widgetTest("logo with dark mode alternative", {
@@ -126,7 +126,7 @@ widgetTest("logo with dark mode alternative", {
darkLogo,
"includes dark mode alternative logo source"
);
}
},
});
widgetTest("mobile logo with dark mode alternative", {
@@ -156,7 +156,7 @@ widgetTest("mobile logo with dark mode alternative", {
darkLogo,
"includes dark mode alternative logo source"
);
}
},
});
widgetTest("dark mode enabled but no dark logo set", {
@@ -177,7 +177,7 @@ widgetTest("dark mode enabled but no dark logo set", {
find("picture").length === 0,
"does not include alternative logo"
);
}
},
});
widgetTest("dark logo set but no dark mode", {
@@ -194,7 +194,7 @@ widgetTest("dark logo set but no dark mode", {
find("picture").length === 0,
"does not include alternative logo"
);
}
},
});
widgetTest("dark color scheme and dark logo set", {
@@ -214,7 +214,7 @@ widgetTest("dark color scheme and dark logo set", {
find("picture").length === 0,
"does not add dark mode alternative"
);
}
},
});
widgetTest("dark color scheme and dark logo not set", {
@@ -234,5 +234,5 @@ widgetTest("dark color scheme and dark logo not set", {
bigLogo,
"uses regular logo on dark scheme if no dark logo"
);
}
},
});

View File

@@ -11,14 +11,14 @@ widgetTest("duplicate links", {
{
title: "Evil Trout Link",
url: "http://eviltrout.com",
reflection: true
reflection: true,
},
{
title: "Evil Trout Link",
url: "http://dupe.eviltrout.com",
reflection: true
}
]
reflection: true,
},
],
});
},
test(assert) {
@@ -27,7 +27,7 @@ widgetTest("duplicate links", {
1,
"it hides the dupe link"
);
}
},
});
widgetTest("collapsed links", {
@@ -42,13 +42,13 @@ widgetTest("collapsed links", {
{ title: "Link 4", url: "http://eviltrout.com?4", reflection: true },
{ title: "Link 5", url: "http://eviltrout.com?5", reflection: true },
{ title: "Link 6", url: "http://eviltrout.com?6", reflection: true },
{ title: "Link 7", url: "http://eviltrout.com?7", reflection: true }
]
{ title: "Link 7", url: "http://eviltrout.com?7", reflection: true },
],
});
},
async test(assert) {
assert.ok(find(".expand-links").length === 1, "collapsed by default");
await click("a.expand-links");
assert.equal(find(".post-links a.track-link").length, 7);
}
},
});

View File

@@ -7,14 +7,14 @@ widgetTest("add extra button", {
template: '{{mount-widget widget="post-menu" args=args}}',
beforeEach() {
this.set("args", {});
withPluginApi("0.8", api => {
withPluginApi("0.8", (api) => {
api.addPostMenuButton("coffee", () => {
return {
action: "drinkCoffee",
icon: "coffee",
className: "hot-coffee",
title: "coffee.title",
position: "first"
position: "first",
};
});
});
@@ -24,14 +24,14 @@ widgetTest("add extra button", {
find(".actions .extra-buttons .hot-coffee").length === 1,
"It renders extra button"
);
}
},
});
widgetTest("remove extra button", {
template: '{{mount-widget widget="post-menu" args=args}}',
beforeEach() {
this.set("args", {});
withPluginApi("0.8", api => {
withPluginApi("0.8", (api) => {
api.removePostMenuButton("coffee");
});
},
@@ -40,5 +40,5 @@ widgetTest("remove extra button", {
find(".actions .extra-buttons .hot-coffee").length === 0,
"It doesn't removes coffee button"
);
}
},
});

View File

@@ -10,10 +10,10 @@ function postStreamTest(name, attrs) {
beforeEach() {
const site = this.container.lookup("site:main");
let posts = attrs.posts.call(this);
posts.forEach(p => p.set("site", site));
posts.forEach((p) => p.set("site", site));
this.set("posts", posts);
},
test: attrs.test
test: attrs.test,
});
}
@@ -29,35 +29,35 @@ postStreamTest("basics", {
post_number: 1,
user_id: 123,
primary_group_name: "trout",
avatar_template: "/images/avatar.png"
avatar_template: "/images/avatar.png",
}),
Post.create({
topic,
id: 2,
post_number: 2,
post_type: site.get("post_types.moderator_action")
post_type: site.get("post_types.moderator_action"),
}),
Post.create({ topic, id: 3, post_number: 3, hidden: true }),
Post.create({
topic,
id: 4,
post_number: 4,
post_type: site.get("post_types.whisper")
post_type: site.get("post_types.whisper"),
}),
Post.create({
topic,
id: 5,
post_number: 5,
wiki: true,
via_email: true
via_email: true,
}),
Post.create({
topic,
id: 6,
post_number: 6,
via_email: true,
is_auto_generated: true
})
is_auto_generated: true,
}),
];
},
@@ -114,7 +114,7 @@ postStreamTest("basics", {
1,
"renders the main avatar"
);
}
},
});
postStreamTest("deleted posts", {
@@ -126,8 +126,8 @@ postStreamTest("deleted posts", {
topic,
id: 1,
post_number: 1,
deleted_at: new Date().toString()
})
deleted_at: new Date().toString(),
}),
];
},
@@ -142,5 +142,5 @@ postStreamTest("deleted posts", {
1,
"it has the trash avatar"
);
}
},
});

View File

@@ -15,7 +15,7 @@ widgetTest("basic elements", {
assert.ok(find("a.post-date").length, "includes post date");
assert.ok(find("a.post-date[data-share-url]").length);
assert.ok(find("a.post-date[data-post-number]").length);
}
},
});
widgetTest("post - links", {
@@ -26,14 +26,14 @@ widgetTest("post - links", {
"<a href='http://link1.example.com/'>first link</a> and <a href='http://link2.example.com/?some=query'>second link</a>",
linkCounts: [
{ url: "http://link1.example.com/", clicks: 1, internal: true },
{ url: "http://link2.example.com/", clicks: 2, internal: true }
]
{ url: "http://link2.example.com/", clicks: 2, internal: true },
],
});
},
async test(assert) {
assert.equal(find(".badge.clicks:nth(0)").text(), "1");
assert.equal(find(".badge.clicks:nth(1)").text(), "2");
}
},
});
widgetTest("wiki", {
@@ -49,7 +49,7 @@ widgetTest("wiki", {
this.historyShown,
"clicking the wiki icon displays the post history"
);
}
},
});
widgetTest("wiki without revision", {
@@ -62,7 +62,7 @@ widgetTest("wiki without revision", {
async test(assert) {
await click(".post-info .wiki");
assert.ok(this.editPostCalled, "clicking wiki icon edits the post");
}
},
});
widgetTest("via-email", {
@@ -75,7 +75,7 @@ widgetTest("via-email", {
async test(assert) {
await click(".post-info.via-email");
assert.ok(this.rawEmailShown, "clicking the envelope shows the raw email");
}
},
});
widgetTest("via-email without permission", {
@@ -91,7 +91,7 @@ widgetTest("via-email without permission", {
!this.rawEmailShown,
"clicking the envelope doesn't show the raw email"
);
}
},
});
widgetTest("history", {
@@ -104,7 +104,7 @@ widgetTest("history", {
async test(assert) {
await click(".post-info.edits");
assert.ok(this.historyShown, "clicking the pencil shows the history");
}
},
});
widgetTest("history without view permission", {
@@ -120,7 +120,7 @@ widgetTest("history without view permission", {
!this.historyShown,
`clicking the pencil doesn't show the history`
);
}
},
});
widgetTest("whisper", {
@@ -131,7 +131,7 @@ widgetTest("whisper", {
test(assert) {
assert.ok(find(".topic-post.whisper").length === 1);
assert.ok(find(".post-info.whisper").length === 1);
}
},
});
widgetTest("like count button", {
@@ -143,7 +143,7 @@ widgetTest("like count button", {
post_number: 1,
topic,
like_count: 3,
actions_summary: [{ id: 2, count: 1, hidden: false, can_act: true }]
actions_summary: [{ id: 2, count: 1, hidden: false, can_act: true }],
});
this.set("post", post);
this.set("args", { likeCount: 1 });
@@ -161,7 +161,7 @@ widgetTest("like count button", {
await click("button.like-count");
assert.ok(find(".who-liked").length === 0);
assert.ok(find(".who-liked a.trigger-user-card").length === 0);
}
},
});
widgetTest(`like count with no likes`, {
@@ -171,7 +171,7 @@ widgetTest(`like count with no likes`, {
},
test(assert) {
assert.ok(find("button.like-count").length === 0);
}
},
});
widgetTest("share button", {
@@ -184,7 +184,7 @@ widgetTest("share button", {
!!find(".actions button[data-share-url]").length,
"it renders a share button"
);
}
},
});
widgetTest("liking", {
@@ -211,7 +211,7 @@ widgetTest("liking", {
assert.ok(!!find(".actions button.like").length);
assert.ok(!find(".actions button.has-like").length);
assert.ok(find(".actions button.like-count").length === 0);
}
},
});
widgetTest("anon liking", {
@@ -235,7 +235,7 @@ widgetTest("anon liking", {
await click(".actions button.like");
assert.ok(this.loginShown);
}
},
});
widgetTest("edit button", {
@@ -248,7 +248,7 @@ widgetTest("edit button", {
async test(assert) {
await click("button.edit");
assert.ok(this.editPostCalled, "it triggered the edit action");
}
},
});
widgetTest(`edit button - can't edit`, {
@@ -258,7 +258,7 @@ widgetTest(`edit button - can't edit`, {
},
test(assert) {
assert.equal(find("button.edit").length, 0, `button is not displayed`);
}
},
});
widgetTest("recover button", {
@@ -271,7 +271,7 @@ widgetTest("recover button", {
async test(assert) {
await click("button.delete");
assert.ok(this.deletePostCalled, "it triggered the delete action");
}
},
});
widgetTest("delete topic button", {
@@ -284,7 +284,7 @@ widgetTest("delete topic button", {
async test(assert) {
await click("button.delete");
assert.ok(this.deletePostCalled, "it triggered the delete action");
}
},
});
widgetTest(`delete topic button - can't delete`, {
@@ -294,7 +294,7 @@ widgetTest(`delete topic button - can't delete`, {
},
test(assert) {
assert.equal(find("button.delete").length, 0, `button is not displayed`);
}
},
});
widgetTest(
@@ -304,7 +304,7 @@ widgetTest(
beforeEach() {
this.set("args", {
canDeleteTopic: false,
showFlagDelete: true
showFlagDelete: true,
});
},
@@ -315,7 +315,7 @@ widgetTest(
I18n.t("post.controls.delete_topic_disallowed"),
`shows the right button title for users without permissions`
);
}
},
}
);
@@ -329,7 +329,7 @@ widgetTest("recover topic button", {
async test(assert) {
await click("button.recover");
assert.ok(this.recovered);
}
},
});
widgetTest(`recover topic button - can't recover`, {
@@ -339,7 +339,7 @@ widgetTest(`recover topic button - can't recover`, {
},
test(assert) {
assert.equal(find("button.recover").length, 0, `button is not displayed`);
}
},
});
widgetTest("delete post button", {
@@ -352,7 +352,7 @@ widgetTest("delete post button", {
async test(assert) {
await click("button.delete");
assert.ok(this.deletePostCalled, "it triggered the delete action");
}
},
});
widgetTest(`delete post button - can't delete`, {
@@ -362,7 +362,7 @@ widgetTest(`delete post button - can't delete`, {
},
test(assert) {
assert.equal(find("button.delete").length, 0, `button is not displayed`);
}
},
});
widgetTest("recover post button", {
@@ -375,7 +375,7 @@ widgetTest("recover post button", {
async test(assert) {
await click("button.recover");
assert.ok(this.recovered);
}
},
});
widgetTest(`recover post button - can't recover`, {
@@ -385,7 +385,7 @@ widgetTest(`recover post button - can't recover`, {
},
test(assert) {
assert.equal(find("button.recover").length, 0, `button is not displayed`);
}
},
});
widgetTest(`flagging`, {
@@ -400,7 +400,7 @@ widgetTest(`flagging`, {
await click("button.create-flag");
assert.ok(this.flagsShown, "it triggered the action");
}
},
});
widgetTest(`flagging: can't flag`, {
@@ -410,7 +410,7 @@ widgetTest(`flagging: can't flag`, {
},
test(assert) {
assert.ok(find("button.create-flag").length === 0);
}
},
});
widgetTest(`flagging: can't flag when post is hidden`, {
@@ -420,7 +420,7 @@ widgetTest(`flagging: can't flag when post is hidden`, {
},
test(assert) {
assert.ok(find("button.create-flag").length === 0);
}
},
});
widgetTest(`read indicator`, {
@@ -430,7 +430,7 @@ widgetTest(`read indicator`, {
},
test(assert) {
assert.ok(find(".read-state.read").length);
}
},
});
widgetTest(`unread indicator`, {
@@ -440,7 +440,7 @@ widgetTest(`unread indicator`, {
},
test(assert) {
assert.ok(find(".read-state").length);
}
},
});
widgetTest("reply directly above (supressed)", {
@@ -449,7 +449,7 @@ widgetTest("reply directly above (supressed)", {
this.set("args", {
replyToUsername: "eviltrout",
replyToAvatarTemplate: "/images/avatar.png",
replyDirectlyAbove: true
replyDirectlyAbove: true,
});
},
test(assert) {
@@ -459,7 +459,7 @@ widgetTest("reply directly above (supressed)", {
0,
"doesn't have the avoid tab class"
);
}
},
});
widgetTest("reply a few posts above (supressed)", {
@@ -468,13 +468,13 @@ widgetTest("reply a few posts above (supressed)", {
this.set("args", {
replyToUsername: "eviltrout",
replyToAvatarTemplate: "/images/avatar.png",
replyDirectlyAbove: false
replyDirectlyAbove: false,
});
},
test(assert) {
assert.ok(find("a.reply-to-tab").length, "shows the tab");
assert.equal(find(".avoid-tab").length, 1, "has the avoid tab class");
}
},
});
widgetTest("reply directly above", {
@@ -483,7 +483,7 @@ widgetTest("reply directly above", {
this.set("args", {
replyToUsername: "eviltrout",
replyToAvatarTemplate: "/images/avatar.png",
replyDirectlyAbove: true
replyDirectlyAbove: true,
});
this.siteSettings.suppress_reply_directly_above = false;
},
@@ -492,7 +492,7 @@ widgetTest("reply directly above", {
await click("a.reply-to-tab");
assert.equal(find("section.embedded-posts.top .cooked").length, 1);
assert.equal(find("section.embedded-posts .d-icon-arrow-up").length, 1);
}
},
});
widgetTest("cooked content hidden", {
@@ -505,7 +505,7 @@ widgetTest("cooked content hidden", {
async test(assert) {
await click(".topic-body .expand-hidden");
assert.ok(this.unhidden, "triggers the action");
}
},
});
widgetTest("expand first post", {
@@ -517,7 +517,7 @@ widgetTest("expand first post", {
async test(assert) {
await click(".topic-body .expand-post");
assert.equal(find(".expand-post").length, 0, "button is gone");
}
},
});
widgetTest("can't bookmark", {
@@ -528,7 +528,7 @@ widgetTest("can't bookmark", {
test(assert) {
assert.equal(find("button.bookmark").length, 0);
assert.equal(find("button.bookmarked").length, 0);
}
},
});
widgetTest("bookmark", {
@@ -543,7 +543,7 @@ widgetTest("bookmark", {
async test(assert) {
assert.equal(find(".post-menu-area .bookmark").length, 1);
assert.equal(find("button.bookmarked").length, 0);
}
},
});
widgetTest("can't show admin menu when you can't manage", {
@@ -553,7 +553,7 @@ widgetTest("can't show admin menu when you can't manage", {
},
test(assert) {
assert.equal(find(".post-menu-area .show-post-admin-menu").length, 0);
}
},
});
widgetTest("show admin menu", {
@@ -571,7 +571,7 @@ widgetTest("show admin menu", {
0,
"clicking outside clears the popup"
);
}
},
});
widgetTest("toggle moderator post", {
@@ -588,7 +588,7 @@ widgetTest("toggle moderator post", {
assert.ok(this.toggled);
assert.equal(find(".post-admin-menu").length, 0, "also hides the menu");
}
},
});
widgetTest("toggle moderator post", {
template:
@@ -604,7 +604,7 @@ widgetTest("toggle moderator post", {
assert.ok(this.toggled);
assert.equal(find(".post-admin-menu").length, 0, "also hides the menu");
}
},
});
widgetTest("rebake post", {
@@ -619,7 +619,7 @@ widgetTest("rebake post", {
await click(".post-admin-menu .rebuild-html");
assert.ok(this.baked);
assert.equal(find(".post-admin-menu").length, 0, "also hides the menu");
}
},
});
widgetTest("unhide post", {
@@ -634,7 +634,7 @@ widgetTest("unhide post", {
await click(".post-admin-menu .unhide-post");
assert.ok(this.unhidden);
assert.equal(find(".post-admin-menu").length, 0, "also hides the menu");
}
},
});
widgetTest("change owner", {
@@ -650,7 +650,7 @@ widgetTest("change owner", {
await click(".post-admin-menu .change-owner");
assert.ok(this.owned);
assert.equal(find(".post-admin-menu").length, 0, "also hides the menu");
}
},
});
widgetTest("reply", {
@@ -663,7 +663,7 @@ widgetTest("reply", {
async test(assert) {
await click(".post-controls .create");
assert.ok(this.replied);
}
},
});
widgetTest("reply - without permissions", {
@@ -673,7 +673,7 @@ widgetTest("reply - without permissions", {
},
test(assert) {
assert.equal(find(".post-controls .create").length, 0);
}
},
});
widgetTest("replies - no replies", {
@@ -683,7 +683,7 @@ widgetTest("replies - no replies", {
},
test(assert) {
assert.equal(find("button.show-replies").length, 0);
}
},
});
widgetTest("replies - multiple replies", {
@@ -694,7 +694,7 @@ widgetTest("replies - multiple replies", {
},
test(assert) {
assert.equal(find("button.show-replies").length, 1);
}
},
});
widgetTest("replies - one below, suppressed", {
@@ -705,7 +705,7 @@ widgetTest("replies - one below, suppressed", {
},
test(assert) {
assert.equal(find("button.show-replies").length, 0);
}
},
});
widgetTest("replies - one below, not suppressed", {
@@ -718,7 +718,7 @@ widgetTest("replies - one below, not suppressed", {
await click("button.show-replies");
assert.equal(find("section.embedded-posts.bottom .cooked").length, 1);
assert.equal(find("section.embedded-posts .d-icon-arrow-down").length, 1);
}
},
});
widgetTest("topic map not shown", {
@@ -728,7 +728,7 @@ widgetTest("topic map not shown", {
},
test(assert) {
assert.equal(find(".topic-map").length, 0);
}
},
});
widgetTest("topic map - few posts", {
@@ -737,7 +737,7 @@ widgetTest("topic map - few posts", {
this.set("args", {
showTopicMap: true,
topicPostsCount: 2,
participants: [{ username: "eviltrout" }, { username: "codinghorror" }]
participants: [{ username: "eviltrout" }, { username: "codinghorror" }],
});
},
async test(assert) {
@@ -753,7 +753,7 @@ widgetTest("topic map - few posts", {
2,
"shows all when expanded"
);
}
},
});
widgetTest("topic map - participants", {
@@ -766,9 +766,9 @@ widgetTest("topic map - participants", {
{ username: "eviltrout" },
{ username: "codinghorror" },
{ username: "sam" },
{ username: "ZogStrIP" }
{ username: "ZogStrIP" },
],
userFilters: ["sam", "codinghorror"]
userFilters: ["sam", "codinghorror"],
});
},
async test(assert) {
@@ -786,7 +786,7 @@ widgetTest("topic map - participants", {
"shows all when expanded"
);
assert.equal(find("a.poster.toggled").length, 2, "two are toggled");
}
},
});
widgetTest("topic map - links", {
@@ -800,8 +800,8 @@ widgetTest("topic map - links", {
{ url: "http://link3.example.com", clicks: 0 },
{ url: "http://link4.example.com", clicks: 0 },
{ url: "http://link5.example.com", clicks: 0 },
{ url: "http://link6.example.com", clicks: 0 }
]
{ url: "http://link6.example.com", clicks: 0 },
],
});
},
async test(assert) {
@@ -825,7 +825,7 @@ widgetTest("topic map - links", {
6,
"all links now shown"
);
}
},
});
widgetTest("topic map - no summary", {
@@ -835,7 +835,7 @@ widgetTest("topic map - no summary", {
},
test(assert) {
assert.equal(find(".toggle-summary").length, 0);
}
},
});
widgetTest("topic map - has summary", {
@@ -850,7 +850,7 @@ widgetTest("topic map - has summary", {
await click(".toggle-summary button");
assert.ok(this.summaryToggled);
}
},
});
widgetTest("pm map", {
@@ -860,13 +860,13 @@ widgetTest("pm map", {
showTopicMap: true,
showPMMap: true,
allowedGroups: [],
allowedUsers: [EmberObject.create({ username: "eviltrout" })]
allowedUsers: [EmberObject.create({ username: "eviltrout" })],
});
},
test(assert) {
assert.equal(find(".private-message-map").length, 1);
assert.equal(find(".private-message-map .user").length, 1);
}
},
});
widgetTest("post notice - with username", {
@@ -882,20 +882,18 @@ widgetTest("post notice - with username", {
noticeTime: twoDaysAgo,
username: "codinghorror",
name: "Jeff",
created_at: new Date()
created_at: new Date(),
});
},
test(assert) {
assert.equal(
find(".post-notice.returning-user:not(.old)")
.text()
.trim(),
find(".post-notice.returning-user:not(.old)").text().trim(),
I18n.t("post.notice.returning_user", {
user: "codinghorror",
time: "2 days ago"
time: "2 days ago",
})
);
}
},
});
widgetTest("post notice - with name", {
@@ -908,17 +906,15 @@ widgetTest("post notice - with name", {
noticeType: "new_user",
username: "codinghorror",
name: "Jeff",
created_at: new Date(2019, 0, 1)
created_at: new Date(2019, 0, 1),
});
},
test(assert) {
assert.equal(
find(".post-notice.old.new-user")
.text()
.trim(),
find(".post-notice.old.new-user").text().trim(),
I18n.t("post.notice.new_user", { user: "Jeff", time: "Jan '10" })
);
}
},
});
widgetTest("show group request in post", {
@@ -926,12 +922,12 @@ widgetTest("show group request in post", {
beforeEach() {
this.set("args", {
username: "foo",
requestedGroupName: "testGroup"
requestedGroupName: "testGroup",
});
},
test(assert) {
const link = find(".group-request a");
assert.equal(link.text().trim(), I18n.t("groups.requests.handle"));
assert.equal(link.attr("href"), "/g/testGroup/requests?filter=foo");
}
},
});

View File

@@ -9,7 +9,7 @@ widgetTest("basic rendering", {
username: "eviltrout",
usernameUrl: "/u/eviltrout",
name: "Robin Ward",
user_title: "Trout Master"
user_title: "Trout Master",
});
},
test(assert) {
@@ -19,7 +19,7 @@ widgetTest("basic rendering", {
assert.equal(find(".username a").text(), "eviltrout");
assert.equal(find(".full-name a").text(), "Robin Ward");
assert.equal(find(".user-title").text(), "Trout Master");
}
},
});
widgetTest("extra classes and glyphs", {
@@ -32,7 +32,7 @@ widgetTest("extra classes and glyphs", {
admin: true,
moderator: true,
new_user: true,
primary_group_name: "fish"
primary_group_name: "fish",
});
},
test(assert) {
@@ -42,7 +42,7 @@ widgetTest("extra classes and glyphs", {
assert.ok(find(".d-icon-shield-alt").length);
assert.ok(find("span.new-user").length);
assert.ok(find("span.fish").length);
}
},
});
widgetTest("disable display name on posts", {
@@ -53,7 +53,7 @@ widgetTest("disable display name on posts", {
},
test(assert) {
assert.equal(find(".full-name").length, 0);
}
},
});
widgetTest("doesn't render a name if it's similar to the username", {
@@ -65,5 +65,5 @@ widgetTest("doesn't render a name if it's similar to the username", {
},
test(assert) {
assert.equal(find(".second").length, 0);
}
},
});

View File

@@ -14,7 +14,7 @@ widgetTest("content attribute is escaped", {
test(assert) {
const contentDiv = find(CONTENT_DIV_SELECTOR)[0];
assert.equal(contentDiv.innerText, "<b>bold</b>");
}
},
});
widgetTest("escapedContent attribute is not escaped", {
@@ -27,5 +27,5 @@ widgetTest("escapedContent attribute is not escaped", {
test(assert) {
const contentDiv = find(CONTENT_DIV_SELECTOR)[0];
assert.equal(contentDiv.innerText, '"quote"');
}
},
});

View File

@@ -8,13 +8,13 @@ widgetTest("renders avatars and support for unknown", {
this.set("args", {
users: [
{ id: 456, username: "eviltrout" },
{ id: 457, username: "someone", unknown: true }
]
{ id: 457, username: "someone", unknown: true },
],
});
},
async test(assert) {
assert.ok(find("[data-user-card=eviltrout]").length === 1);
assert.ok(find("[data-user-card=someone]").length === 0);
assert.ok(find(".unknown").length, "includes unkown user");
}
},
});

View File

@@ -4,7 +4,7 @@ import Category from "discourse/models/category";
moduleForWidget("topic-admin-menu-button");
const createArgs = topic => {
const createArgs = (topic) => {
return {
topic: topic,
openUpwards: "true",
@@ -19,7 +19,7 @@ const createArgs = topic => {
showChangeTimestamp: () => {},
resetBumpDate: () => {},
convertToPublicTopic: () => {},
convertToPrivateMessage: () => {}
convertToPrivateMessage: () => {},
};
};
@@ -30,7 +30,7 @@ widgetTest("topic-admin-menu-button is present for admin/moderators", {
this.currentUser.setProperties({
admin: true,
moderator: true,
id: 123
id: 123,
});
const topic = Topic.create({ user_id: this.currentUser.id });
topic.category = Category.create({ read_restricted: true });
@@ -40,7 +40,7 @@ widgetTest("topic-admin-menu-button is present for admin/moderators", {
test(assert) {
assert.ok(exists(".toggle-admin-menu"), "admin wrench is present");
}
},
});
widgetTest(
@@ -52,7 +52,7 @@ widgetTest(
this.currentUser.setProperties({
admin: false,
moderator: false,
id: 123
id: 123,
});
const topic = Topic.create({ user_id: this.currentUser.id });
topic.category = Category.create({ read_restricted: true });
@@ -62,6 +62,6 @@ widgetTest(
test(assert) {
assert.ok(!exists(".toggle-admin-menu"), "admin wrench is not present");
}
},
}
);

View File

@@ -9,7 +9,7 @@ widgetTest("one post", {
this.set("args", {
username: "test",
avatar_template: "/images/avatar.png",
post_count: 1
post_count: 1,
});
},
@@ -17,7 +17,7 @@ widgetTest("one post", {
assert.ok(exists("a.poster.trigger-user-card"));
assert.ok(!exists("span.post-count"), "don't show count for only 1 post");
assert.ok(!exists(".avatar-flair"), "no avatar flair");
}
},
});
widgetTest("many posts, a primary group with flair", {
@@ -30,7 +30,7 @@ widgetTest("many posts, a primary group with flair", {
post_count: 5,
primary_group_name: "devs",
primary_group_flair_url: "/images/d-logo-sketch-small.png",
primary_group_flair_bg_color: "222"
primary_group_flair_bg_color: "222",
});
},
@@ -45,5 +45,5 @@ widgetTest("many posts, a primary group with flair", {
exists(".avatar-flair.avatar-flair-devs"),
"show flair with group class"
);
}
},
});

View File

@@ -8,12 +8,12 @@ widgetTest("basics", {
beforeEach(store) {
this.set("args", {
topic: store.createRecord("topic", { closed: true }),
disableActions: true
disableActions: true,
});
},
test(assert) {
assert.ok(find(".topic-status .d-icon-lock").length);
}
},
});
widgetTest("extendability", {
@@ -22,16 +22,16 @@ widgetTest("extendability", {
TopicStatusIcons.addObject([
"has_accepted_answer",
"far-check-square",
"solved"
"solved",
]);
this.set("args", {
topic: store.createRecord("topic", {
has_accepted_answer: true
has_accepted_answer: true,
}),
disableActions: true
disableActions: true,
});
},
test(assert) {
assert.ok(find(".topic-status .d-icon-far-check-square").length);
}
},
});

View File

@@ -14,7 +14,7 @@ widgetTest("basics", {
assert.ok(find(".user-bookmarks-link").length);
assert.ok(find(".quick-access-panel").length);
assert.ok(find(".notifications-dismiss").length);
}
},
});
widgetTest("notifications", {
@@ -35,7 +35,7 @@ widgetTest("notifications", {
assert.equal(
$links[1].text,
`aquaman ${I18n.t("notifications.liked_consolidated_description", {
count: 5
count: 5,
})}`
);
@@ -44,7 +44,7 @@ widgetTest("notifications", {
$links[2].innerHTML.includes(
I18n.t("notifications.group_message_summary", {
count: 5,
group_name: "test"
group_name: "test",
})
)
);
@@ -60,7 +60,7 @@ widgetTest("notifications", {
assert.ok(
$links[4].innerHTML.includes(
I18n.t("notifications.membership_request_accepted", {
group_name: "test"
group_name: "test",
})
)
);
@@ -71,7 +71,7 @@ widgetTest("notifications", {
routeToStub.calledWith(find(".user-notifications-link")[0].href),
"a second click should redirect to the full notifications page"
);
}
},
});
widgetTest("log out", {
@@ -87,7 +87,7 @@ widgetTest("log out", {
await click(".logout");
assert.ok(this.loggedOut);
}
},
});
widgetTest("private messages - disabled", {
@@ -98,7 +98,7 @@ widgetTest("private messages - disabled", {
test(assert) {
assert.ok(!find(".user-pms-link").length);
}
},
});
widgetTest("private messages - enabled", {
@@ -134,7 +134,7 @@ widgetTest("private messages - enabled", {
routeToStub.calledWith(userPmsLink.href),
"a second click should redirect to the full private messages page"
);
}
},
});
widgetTest("bookmarks", {
@@ -162,7 +162,7 @@ widgetTest("bookmarks", {
routeToStub.calledWith(find(".user-bookmarks-link")[0].href),
"a second click should redirect to the full bookmarks page"
);
}
},
});
widgetTest("anonymous", {
@@ -183,7 +183,7 @@ widgetTest("anonymous", {
await click(".enable-anonymous");
assert.ok(this.anonymous);
}
},
});
widgetTest("anonymous - disabled", {
@@ -196,7 +196,7 @@ widgetTest("anonymous - disabled", {
async test(assert) {
await click(".user-preferences-link");
assert.ok(!find(".enable-anonymous").length);
}
},
});
widgetTest("anonymous - switch back", {
@@ -216,5 +216,5 @@ widgetTest("anonymous - switch back", {
await click(".disable-anonymous");
assert.notOk(this.anonymous);
}
},
});

View File

@@ -9,9 +9,9 @@ const DEFAULT_CONTENT = {
{ id: 2, translatedLabel: "FooBar" },
"separator",
{ id: 3, translatedLabel: "With icon", icon: "times" },
{ id: 4, html: "<b>baz</b>" }
{ id: 4, html: "<b>baz</b>" },
],
label: "foo"
label: "foo",
};
async function clickRowById(id) {
@@ -63,7 +63,7 @@ widgetTest("dropdown id", {
test(assert) {
assert.ok(exists("#my-dropdown"));
}
},
});
widgetTest("label", {
@@ -82,7 +82,7 @@ widgetTest("label", {
test(assert) {
assert.equal(headerLabel(), "FooBaz");
}
},
});
widgetTest("translatedLabel", {
@@ -102,7 +102,7 @@ widgetTest("translatedLabel", {
test(assert) {
assert.equal(headerLabel(), this.translatedLabel);
}
},
});
widgetTest("content", {
@@ -117,7 +117,7 @@ widgetTest("content", {
assert.equal(rowById(1).dataset.id, 1, "it creates rows");
assert.equal(rowById(2).dataset.id, 2, "it creates rows");
assert.equal(rowById(3).dataset.id, 3, "it creates rows");
}
},
});
widgetTest("onChange action", {
@@ -139,7 +139,7 @@ widgetTest("onChange action", {
this.on(
"onChange",
item => (this._element.querySelector("#test").innerText = item.id)
(item) => (this._element.querySelector("#test").innerText = item.id)
);
},
@@ -147,7 +147,7 @@ widgetTest("onChange action", {
await toggle();
await clickRowById(2);
assert.equal(find("#test").text(), 2, "it calls the onChange actions");
}
},
});
widgetTest("can be opened and closed", {
@@ -167,7 +167,7 @@ widgetTest("can be opened and closed", {
await toggle();
assert.ok(exists("#my-dropdown.closed"));
assert.ok(!exists("#my-dropdown .widget-dropdown-body"));
}
},
});
widgetTest("icon", {
@@ -180,7 +180,7 @@ widgetTest("icon", {
test(assert) {
assert.ok(exists(header().querySelector(".d-icon-times")));
}
},
});
widgetTest("class", {
@@ -193,7 +193,7 @@ widgetTest("class", {
test(assert) {
assert.ok(exists("#my-dropdown.activated"));
}
},
});
widgetTest("content with translatedLabel", {
@@ -206,7 +206,7 @@ widgetTest("content with translatedLabel", {
async test(assert) {
await toggle();
assert.equal(rowById(2).innerText.trim(), "FooBar");
}
},
});
widgetTest("content with label", {
@@ -226,7 +226,7 @@ widgetTest("content with label", {
async test(assert) {
await toggle();
assert.equal(rowById(1).innerText.trim(), "FooBaz");
}
},
});
widgetTest("content with icon", {
@@ -239,7 +239,7 @@ widgetTest("content with icon", {
async test(assert) {
await toggle();
assert.ok(exists(rowById(3).querySelector(".d-icon-times")));
}
},
});
widgetTest("content with html", {
@@ -252,7 +252,7 @@ widgetTest("content with html", {
async test(assert) {
await toggle();
assert.equal(rowById(4).innerHTML.trim(), "<span><b>baz</b></span>");
}
},
});
widgetTest("separator", {
@@ -269,7 +269,7 @@ widgetTest("separator", {
"#my-dropdown .widget-dropdown-item:nth-child(3)"
)[0].classList.contains("separator")
);
}
},
});
widgetTest("hides widget if no content", {
@@ -282,7 +282,7 @@ widgetTest("hides widget if no content", {
test(assert) {
assert.notOk(exists("#my-dropdown .widget-dropdown-header"));
assert.notOk(exists("#my-dropdown .widget-dropdown-body"));
}
},
});
widgetTest("headerClass option", {
@@ -297,7 +297,7 @@ widgetTest("headerClass option", {
assert.ok(header().classList.contains("widget-dropdown-header"));
assert.ok(header().classList.contains("btn-small"));
assert.ok(header().classList.contains("and-text"));
}
},
});
widgetTest("bodyClass option", {
@@ -313,7 +313,7 @@ widgetTest("bodyClass option", {
assert.ok(body().classList.contains("widget-dropdown-body"));
assert.ok(body().classList.contains("gigantic"));
assert.ok(body().classList.contains("and-yet-small"));
}
},
});
widgetTest("caret option", {
@@ -328,5 +328,5 @@ widgetTest("caret option", {
assert.ok(
exists("#my-dropdown .widget-dropdown-header .d-icon-caret-down")
);
}
},
});

View File

@@ -14,7 +14,7 @@ widgetTest("widget attributes are passed in via args", {
beforeEach() {
createWidget("hello-test", {
tagName: "div.test",
template: hbs`Hello {{attrs.name}}`
template: hbs`Hello {{attrs.name}}`,
});
this.set("args", { name: "Robin" });
@@ -22,7 +22,7 @@ widgetTest("widget attributes are passed in via args", {
test(assert) {
assert.equal(find(".test").text(), "Hello Robin");
}
},
});
widgetTest("hbs template - no tagName", {
@@ -30,7 +30,7 @@ widgetTest("hbs template - no tagName", {
beforeEach() {
createWidget("hbs-test", {
template: hbs`<div class='test'>Hello {{attrs.name}}</div>`
template: hbs`<div class='test'>Hello {{attrs.name}}</div>`,
});
this.set("args", { name: "Robin" });
@@ -38,7 +38,7 @@ widgetTest("hbs template - no tagName", {
test(assert) {
assert.equal(find("div.test").text(), "Hello Robin");
}
},
});
widgetTest("hbs template - with tagName", {
@@ -47,7 +47,7 @@ widgetTest("hbs template - with tagName", {
beforeEach() {
createWidget("hbs-test", {
tagName: "div.test",
template: hbs`Hello {{attrs.name}}`
template: hbs`Hello {{attrs.name}}`,
});
this.set("args", { name: "Robin" });
@@ -55,7 +55,7 @@ widgetTest("hbs template - with tagName", {
test(assert) {
assert.equal(find("div.test").text(), "Hello Robin");
}
},
});
widgetTest("hbs template - with data attributes", {
@@ -63,13 +63,13 @@ widgetTest("hbs template - with data attributes", {
beforeEach() {
createWidget("hbs-test", {
template: hbs`<div class='mydiv' data-my-test='hello world'></div>`
template: hbs`<div class='mydiv' data-my-test='hello world'></div>`,
});
},
test(assert) {
assert.equal(find("div.mydiv").data("my-test"), "hello world");
}
},
});
widgetTest("buildClasses", {
@@ -81,7 +81,7 @@ widgetTest("buildClasses", {
buildClasses(attrs) {
return ["static", attrs.dynamic];
}
},
});
this.set("args", { dynamic: "cool-class" });
@@ -89,7 +89,7 @@ widgetTest("buildClasses", {
test(assert) {
assert.ok(find(".test.static.cool-class").length, "it has all the classes");
}
},
});
widgetTest("buildAttributes", {
@@ -101,7 +101,7 @@ widgetTest("buildAttributes", {
buildAttributes(attrs) {
return { "data-evil": "trout", "aria-label": attrs.label };
}
},
});
this.set("args", { label: "accessibility" });
@@ -110,7 +110,7 @@ widgetTest("buildAttributes", {
test(assert) {
assert.ok(find(".test[data-evil=trout]").length);
assert.ok(find(".test[aria-label=accessibility]").length);
}
},
});
widgetTest("buildId", {
@@ -120,7 +120,7 @@ widgetTest("buildId", {
createWidget("id-test", {
buildId(attrs) {
return `test-${attrs.id}`;
}
},
});
this.set("args", { id: 1234 });
@@ -128,7 +128,7 @@ widgetTest("buildId", {
test(assert) {
assert.ok(find("#test-1234").length);
}
},
});
widgetTest("widget state", {
@@ -146,7 +146,7 @@ widgetTest("widget state", {
click() {
this.state.clicks++;
}
},
});
},
@@ -156,7 +156,7 @@ widgetTest("widget state", {
await click(find("button"));
assert.equal(find("button.test").text(), "1 clicks");
}
},
});
widgetTest("widget update with promise", {
@@ -175,32 +175,22 @@ widgetTest("widget update with promise", {
`,
click() {
return new Promise(resolve => {
return new Promise((resolve) => {
next(() => {
this.state.name = "Robin";
resolve();
});
});
}
},
});
},
async test(assert) {
assert.equal(
find("button.test")
.text()
.trim(),
"No name"
);
assert.equal(find("button.test").text().trim(), "No name");
await click(find("button"));
assert.equal(
find("button.test")
.text()
.trim(),
"Robin"
);
}
assert.equal(find("button.test").text().trim(), "Robin");
},
});
widgetTest("widget attaching", {
@@ -211,14 +201,14 @@ widgetTest("widget attaching", {
createWidget("attach-test", {
tagName: "div.container",
template: hbs`{{attach widget="test-embedded" attrs=attrs}}`
template: hbs`{{attach widget="test-embedded" attrs=attrs}}`,
});
},
test(assert) {
assert.ok(find(".container").length, "renders container");
assert.ok(find(".container .embedded").length, "renders attached");
}
},
});
widgetTest("magic attaching by name", {
@@ -229,14 +219,14 @@ widgetTest("magic attaching by name", {
createWidget("attach-test", {
tagName: "div.container",
template: hbs`{{test-embedded attrs=attrs}}`
template: hbs`{{test-embedded attrs=attrs}}`,
});
},
test(assert) {
assert.ok(find(".container").length, "renders container");
assert.ok(find(".container .embedded").length, "renders attached");
}
},
});
widgetTest("custom attrs to a magic attached widget", {
@@ -245,19 +235,19 @@ widgetTest("custom attrs to a magic attached widget", {
beforeEach() {
createWidget("testing", {
tagName: "span.value",
template: hbs`{{attrs.value}}`
template: hbs`{{attrs.value}}`,
});
createWidget("attach-test", {
tagName: "div.container",
template: hbs`{{testing value=(concat "hello" " " "world")}}`
template: hbs`{{testing value=(concat "hello" " " "world")}}`,
});
},
test(assert) {
assert.ok(find(".container").length, "renders container");
assert.equal(find(".container .value").text(), "hello world");
}
},
});
widgetTest("handlebars d-icon", {
@@ -265,13 +255,13 @@ widgetTest("handlebars d-icon", {
beforeEach() {
createWidget("hbs-icon-test", {
template: hbs`{{d-icon "arrow-down"}}`
template: hbs`{{d-icon "arrow-down"}}`,
});
},
test(assert) {
assert.equal(find(".d-icon-arrow-down").length, 1);
}
},
});
widgetTest("handlebars i18n", {
@@ -285,15 +275,15 @@ widgetTest("handlebars i18n", {
<span class='string'>{{i18n "hbs_test0"}}</span>
<span class='var'>{{i18n attrs.key}}</span>
<a href title={{i18n "hbs_test0"}}>test</a>
`
`,
});
I18n.translations = {
en: {
js: {
hbs_test0: "evil",
hbs_test1: "trout"
}
}
hbs_test1: "trout",
},
},
};
this.set("args", { key: "hbs_test1" });
},
@@ -307,7 +297,7 @@ widgetTest("handlebars i18n", {
assert.equal(find("span.string").text(), "evil");
assert.equal(find("span.var").text(), "trout");
assert.equal(find("a").prop("title"), "evil");
}
},
});
widgetTest("handlebars #each", {
@@ -320,18 +310,18 @@ widgetTest("handlebars #each", {
{{#each attrs.items as |item|}}
<li>{{item}}</li>
{{/each}}
`
`,
});
this.set("args", {
items: ["one", "two", "three"]
items: ["one", "two", "three"],
});
},
test(assert) {
assert.equal(find("ul li").length, 3);
assert.equal(find("ul li:eq(0)").text(), "one");
}
},
});
widgetTest("widget decorating", {
@@ -340,15 +330,15 @@ widgetTest("widget decorating", {
beforeEach() {
createWidget("decorate-test", {
tagName: "div.decorate",
template: hbs`main content`
template: hbs`main content`,
});
withPluginApi("0.1", api => {
api.decorateWidget("decorate-test:before", dec => {
withPluginApi("0.1", (api) => {
api.decorateWidget("decorate-test:before", (dec) => {
return dec.h("b", "before");
});
api.decorateWidget("decorate-test:after", dec => {
api.decorateWidget("decorate-test:after", (dec) => {
return dec.h("i", "after");
});
});
@@ -358,7 +348,7 @@ widgetTest("widget decorating", {
assert.ok(find(".decorate").length);
assert.equal(find(".decorate b").text(), "before");
assert.equal(find(".decorate i").text(), "after");
}
},
});
widgetTest("widget settings", {
@@ -368,13 +358,13 @@ widgetTest("widget settings", {
createWidget("settings-test", {
tagName: "div.settings",
template: hbs`age is {{settings.age}}`,
settings: { age: 36 }
settings: { age: 36 },
});
},
test(assert) {
assert.equal(find(".settings").text(), "age is 36");
}
},
});
widgetTest("override settings", {
@@ -384,17 +374,17 @@ widgetTest("override settings", {
createWidget("ov-settings-test", {
tagName: "div.settings",
template: hbs`age is {{settings.age}}`,
settings: { age: 36 }
settings: { age: 36 },
});
withPluginApi("0.1", api => {
withPluginApi("0.1", (api) => {
api.changeWidgetSetting("ov-settings-test", "age", 37);
});
},
test(assert) {
assert.equal(find(".settings").text(), "age is 37");
}
},
});
widgetTest("get accessor", {
@@ -406,13 +396,13 @@ widgetTest("get accessor", {
template: hbs`Hello {{transformed.name}}`,
transform() {
return {
name: this.get("currentUser.username")
name: this.get("currentUser.username"),
};
}
},
});
},
test(assert) {
assert.equal(find("div.test").text(), "Hello eviltrout");
}
},
});