2018-06-15 11:03:24 -04:00
|
|
|
import { moduleForWidget, widgetTest } from "helpers/widget-test";
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
moduleForWidget("poster-name");
|
2016-01-04 15:18:09 -05:00
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("basic rendering", {
|
2016-01-04 15:18:09 -05:00
|
|
|
template: '{{mount-widget widget="poster-name" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", {
|
|
|
|
username: "eviltrout",
|
|
|
|
usernameUrl: "/u/eviltrout",
|
|
|
|
name: "Robin Ward",
|
|
|
|
user_title: "Trout Master"
|
|
|
|
});
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.ok(this.$(".names").length);
|
|
|
|
assert.ok(this.$("span.username").length);
|
|
|
|
assert.ok(this.$("a[data-user-card=eviltrout]").length);
|
|
|
|
assert.equal(this.$(".username a").text(), "eviltrout");
|
|
|
|
assert.equal(this.$(".full-name a").text(), "Robin Ward");
|
|
|
|
assert.equal(this.$(".user-title").text(), "Trout Master");
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("extra classes and glyphs", {
|
2016-01-04 15:18:09 -05:00
|
|
|
template: '{{mount-widget widget="poster-name" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", {
|
|
|
|
username: "eviltrout",
|
|
|
|
usernameUrl: "/u/eviltrout",
|
2016-01-04 15:18:09 -05:00
|
|
|
staff: true,
|
|
|
|
admin: true,
|
|
|
|
moderator: true,
|
|
|
|
new_user: true,
|
2018-06-15 11:03:24 -04:00
|
|
|
primary_group_name: "fish"
|
|
|
|
});
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.ok(this.$("span.staff").length);
|
|
|
|
assert.ok(this.$("span.admin").length);
|
|
|
|
assert.ok(this.$("span.moderator").length);
|
|
|
|
assert.ok(this.$(".d-icon-shield").length);
|
|
|
|
assert.ok(this.$("span.new-user").length);
|
|
|
|
assert.ok(this.$("span.fish").length);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-06-15 11:03:24 -04:00
|
|
|
widgetTest("disable display name on posts", {
|
2016-01-04 15:18:09 -05:00
|
|
|
template: '{{mount-widget widget="poster-name" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-01-04 15:18:09 -05:00
|
|
|
this.siteSettings.display_name_on_posts = false;
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { username: "eviltrout", name: "Robin Ward" });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(this.$(".full-name").length, 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("doesn't render a name if it's similar to the username", {
|
|
|
|
template: '{{mount-widget widget="poster-name" args=args}}',
|
2017-06-14 13:57:58 -04:00
|
|
|
beforeEach() {
|
2016-06-08 00:57:13 -04:00
|
|
|
this.siteSettings.prioritize_username_in_ux = true;
|
|
|
|
this.siteSettings.display_name_on_posts = true;
|
2018-06-15 11:03:24 -04:00
|
|
|
this.set("args", { username: "eviltrout", name: "evil-trout" });
|
2016-01-04 15:18:09 -05:00
|
|
|
},
|
|
|
|
test(assert) {
|
2018-06-15 11:03:24 -04:00
|
|
|
assert.equal(this.$(".second").length, 0);
|
2016-01-04 15:18:09 -05:00
|
|
|
}
|
|
|
|
});
|