discourse/plugins/discourse-gamification/test/javascripts/components/gamification-score-test.gjs
Martin Brennan 79d1c792eb
DEV: Update test module name conventions (#40389)
Currently, most of the JS test modules follow this
convention:

```
module("Integration | Component | topic-dismiss-buttons"
```

Which is a legacy from when ember components etc were
rendered in templates like this:

```
{{d-button title="foo"}}
```

Instead, this commit updates all of them to follow this
PascalCase convention:

```
module("Integration | Component | TopicDismissButtons", function (hooks) {
```

No linting is added to enforce this, we suspect that it's
mostly a result of cargo culting, and people will add new
tests following PascalCase convention.

Also adds an initial AI skill for writing JS tests.
2026-05-29 15:19:55 +10:00

29 lines
1.1 KiB
Text
Vendored

import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import GamificationScore from "../discourse/components/gamification-score";
module(
"Discourse Gamification | Component | GamificationScore",
function (hooks) {
setupRenderingTest(hooks);
test("Scores click link to leaderboard", async function (assert) {
this.site.default_gamification_leaderboard_id = 1;
const user = { id: "1", username: "charlie", gamification_score: 1 };
await render(<template><GamificationScore @model={{user}} /></template>);
assert.dom(".gamification-score a").exists("scores are not clickable");
});
test("Scores show up and are not clickable", async function (assert) {
const user = { id: "1", username: "charlie", gamification_score: 1 };
await render(<template><GamificationScore @model={{user}} /></template>);
assert.dom(".gamification-score").exists("scores not showing up");
assert.dom(".gamification-score a").doesNotExist("scores are clickable");
});
}
);