DEV: Add remove button function to PluginAPI (#9627)

This commit is contained in:
Zdravko Curic
2020-05-05 15:18:02 +02:00
committed by GitHub
parent 6b14a0f352
commit 8010e1ab2e
3 changed files with 64 additions and 1 deletions

View File

@ -0,0 +1,44 @@
import { moduleForWidget, widgetTest } from "helpers/widget-test";
import { withPluginApi } from "discourse/lib/plugin-api";
moduleForWidget("post-menu");
widgetTest("add extra button", {
template: '{{mount-widget widget="post-menu" args=args}}',
beforeEach() {
this.set("args", {});
withPluginApi("0.8", api => {
api.addPostMenuButton("coffee", () => {
return {
action: "drinkCoffee",
icon: "coffee",
className: "hot-coffee",
title: "coffee.title",
position: "first"
};
});
});
},
async test(assert) {
assert.ok(
find(".actions .extra-buttons .hot-coffee").length === 1,
"It renders extra button"
);
}
});
widgetTest("remove extra button", {
template: '{{mount-widget widget="post-menu" args=args}}',
beforeEach() {
this.set("args", {});
withPluginApi("0.8", api => {
api.removePostMenuButton("coffee");
});
},
async test(assert) {
assert.ok(
find(".actions .extra-buttons .hot-coffee").length === 0,
"It doesn't removes coffee button"
);
}
});