2016-01-05 04:18:09 +08:00
|
|
|
import { moduleForWidget, widgetTest } from 'helpers/widget-test';
|
|
|
|
|
|
|
|
moduleForWidget('poster-name');
|
|
|
|
|
|
|
|
widgetTest('basic rendering', {
|
|
|
|
template: '{{mount-widget widget="poster-name" args=args}}',
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2016-01-05 04:18:09 +08:00
|
|
|
this.set('args', {
|
|
|
|
username: 'eviltrout',
|
2017-03-29 02:27:54 +08:00
|
|
|
usernameUrl: '/u/eviltrout',
|
2016-01-05 04:18:09 +08:00
|
|
|
name: 'Robin Ward',
|
|
|
|
user_title: 'Trout Master' });
|
|
|
|
},
|
|
|
|
test(assert) {
|
|
|
|
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');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest('extra classes and glyphs', {
|
|
|
|
template: '{{mount-widget widget="poster-name" args=args}}',
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2016-01-05 04:18:09 +08:00
|
|
|
this.set('args', {
|
|
|
|
username: 'eviltrout',
|
2017-03-29 02:27:54 +08:00
|
|
|
usernameUrl: '/u/eviltrout',
|
2016-01-05 04:18:09 +08:00
|
|
|
staff: true,
|
|
|
|
admin: true,
|
|
|
|
moderator: true,
|
|
|
|
new_user: true,
|
2016-09-17 03:33:51 +08:00
|
|
|
primary_group_name: 'fish'
|
2016-01-05 04:18:09 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
test(assert) {
|
|
|
|
assert.ok(this.$('span.staff').length);
|
|
|
|
assert.ok(this.$('span.admin').length);
|
|
|
|
assert.ok(this.$('span.moderator').length);
|
2017-07-27 04:33:17 +08:00
|
|
|
assert.ok(this.$('.d-icon-shield').length);
|
2016-01-05 04:18:09 +08:00
|
|
|
assert.ok(this.$('span.new-user').length);
|
|
|
|
assert.ok(this.$('span.fish').length);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest('disable display name on posts', {
|
|
|
|
template: '{{mount-widget widget="poster-name" args=args}}',
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2016-01-05 04:18:09 +08:00
|
|
|
this.siteSettings.display_name_on_posts = false;
|
|
|
|
this.set('args', { username: 'eviltrout', name: 'Robin Ward' });
|
|
|
|
},
|
|
|
|
test(assert) {
|
|
|
|
assert.equal(this.$('.full-name').length, 0);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
|
|
|
widgetTest("doesn't render a name if it's similar to the username", {
|
|
|
|
template: '{{mount-widget widget="poster-name" args=args}}',
|
2017-06-15 01:57:58 +08:00
|
|
|
beforeEach() {
|
2016-06-08 12:57:13 +08:00
|
|
|
this.siteSettings.prioritize_username_in_ux = true;
|
|
|
|
this.siteSettings.display_name_on_posts = true;
|
2016-01-05 04:18:09 +08:00
|
|
|
this.set('args', { username: 'eviltrout', name: 'evil-trout' });
|
|
|
|
},
|
|
|
|
test(assert) {
|
2016-06-08 12:57:13 +08:00
|
|
|
assert.equal(this.$('.second').length, 0);
|
2016-01-05 04:18:09 +08:00
|
|
|
}
|
|
|
|
});
|