This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/components/user-info-test.js
Joffrey JAFFEUX 8f03baaf8e
DEV: optionally removes links/avatars from user-info (#16388)
Usage:

```
{{user-info user=user includeLink=false includeAvatar=false}}
```

This is useful when using user-info in a dropdown list for example.
2022-04-06 14:07:38 +02:00

40 lines
1.0 KiB
JavaScript

import componentTest, {
setupRenderingTest,
} from "discourse/tests/helpers/component-test";
import hbs from "htmlbars-inline-precompile";
import { discourseModule, exists } from "discourse/tests/helpers/qunit-helpers";
discourseModule("Integration | Component | user-info", function (hooks) {
setupRenderingTest(hooks);
componentTest("includeLink", {
template: hbs`{{user-info user=currentUser includeLink=includeLink}}`,
async test(assert) {
this.set("includeLink", true);
assert.ok(exists(`.username a[href="/u/${this.currentUser.username}"]`));
this.set("includeLink", false);
assert.notOk(
exists(`.username a[href="/u/${this.currentUser.username}"]`)
);
},
});
componentTest("includeAvatar", {
template: hbs`{{user-info user=currentUser includeAvatar=includeAvatar}}`,
async test(assert) {
this.set("includeAvatar", true);
assert.ok(exists(".user-image"));
this.set("includeAvatar", false);
assert.notOk(exists(".user-image"));
},
});
});