This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/widgets/post-menu-test.js
Robin Ward 435a9913a4 REFACTOR: Replace global find with queryAll
In newer Embers jQuery is removed. There is a `find` but it only returns
one element and not a jQuery selector. This patch migrates our code to a
new helper `queryAll` which allows us to remove the global.
2020-10-29 14:45:51 -04:00

49 lines
1.2 KiB
JavaScript

import { queryAll } from "discourse/tests/helpers/qunit-helpers";
import {
moduleForWidget,
widgetTest,
} from "discourse/tests/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(
queryAll(".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(
queryAll(".actions .extra-buttons .hot-coffee").length === 0,
"It doesn't removes coffee button"
);
},
});