DEV: adds tests for transformers (#28207)

This commit adds tests for:
- header-notifications-avatar-size
- home-logo-href
This commit is contained in:
Joffrey JAFFEUX 2024-08-07 20:58:56 +02:00 committed by GitHub
parent a9abaf408d
commit 1b69c0c721
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 48 additions and 0 deletions

View File

@ -0,0 +1,27 @@
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { withPluginApi } from "discourse/lib/plugin-api";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("header-notifications-avatar-size transformer", function (needs) {
needs.user();
test("applying a value transformation", async function (assert) {
withPluginApi("1.34.0", (api) => {
api.registerValueTransformer(
"header-notifications-avatar-size",
() => "huge"
);
});
await visit("/");
assert
.dom(".current-user .avatar")
.hasAttribute("width", "144", "it transforms the avatar width");
assert
.dom(".current-user .avatar")
.hasAttribute("height", "144", "it transforms the avatar height");
});
});

View File

@ -0,0 +1,21 @@
import { visit } from "@ember/test-helpers";
import { test } from "qunit";
import { withPluginApi } from "discourse/lib/plugin-api";
import { acceptance } from "discourse/tests/helpers/qunit-helpers";
acceptance("home-logo-href transformer", function () {
test("applying a value transformation", async function (assert) {
withPluginApi("1.34.0", (api) => {
api.registerValueTransformer(
"home-logo-href",
({ value }) => value + "transformed"
);
});
await visit("/");
assert
.dom(".title > a")
.hasAttribute("href", "/transformed", "it transforms the logo link href");
});
});