2022-11-02 21:41:30 +08:00
|
|
|
import { module, test } from "qunit";
|
|
|
|
import {
|
|
|
|
chatComposerButtons,
|
|
|
|
chatComposerButtonsDependentKeys,
|
|
|
|
clearChatComposerButtons,
|
|
|
|
registerChatComposerButton,
|
|
|
|
} from "discourse/plugins/chat/discourse/lib/chat-composer-buttons";
|
|
|
|
|
|
|
|
module("Discourse Chat | Unit | chat-composer-buttons", function (hooks) {
|
|
|
|
hooks.beforeEach(function () {
|
|
|
|
registerChatComposerButton({
|
|
|
|
id: "foo",
|
2024-09-13 23:50:52 +08:00
|
|
|
icon: "xmark",
|
2022-11-02 21:41:30 +08:00
|
|
|
dependentKeys: ["test"],
|
|
|
|
});
|
|
|
|
|
|
|
|
registerChatComposerButton({
|
|
|
|
id: "bar",
|
|
|
|
translatedLabel() {
|
|
|
|
return this.baz;
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
hooks.afterEach(function () {
|
|
|
|
clearChatComposerButtons();
|
|
|
|
});
|
|
|
|
|
|
|
|
test("chatComposerButtons", function (assert) {
|
|
|
|
const button = chatComposerButtons({ baz: "fooz" }, "inline")[1];
|
|
|
|
assert.equal(button.id, "bar");
|
|
|
|
assert.equal(button.label, "fooz");
|
|
|
|
});
|
|
|
|
|
|
|
|
test("chatComposerButtonsDependentKeys", function (assert) {
|
|
|
|
assert.deepEqual(chatComposerButtonsDependentKeys(), ["test"]);
|
|
|
|
});
|
|
|
|
});
|