mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 10:20:58 -06:00
DEV: adds tests for transformers (#28207)
This commit adds tests for: - header-notifications-avatar-size - home-logo-href
This commit is contained in:
parent
a9abaf408d
commit
1b69c0c721
@ -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");
|
||||
});
|
||||
});
|
@ -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");
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user