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/plugins/poll/test/javascripts/acceptance/poll-pie-chart-test.js.es6
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

41 lines
1005 B
JavaScript

import { acceptance } from "discourse/tests/helpers/qunit-helpers";
import { queryAll } from "discourse/tests/helpers/qunit-helpers";
acceptance("Rendering polls with pie charts", function (needs) {
needs.user();
needs.settings({
poll_enabled: true,
poll_groupable_user_fields: "something",
});
test("Displays the pie chart", async (assert) => {
await visit("/t/-/topic_with_pie_chart_poll");
const poll = queryAll(".poll")[0];
assert.equal(
queryAll(".info-number", poll)[0].innerHTML,
"2",
"it should display the right number of voters"
);
assert.equal(
queryAll(".info-number", poll)[1].innerHTML,
"5",
"it should display the right number of votes"
);
assert.equal(
poll.classList.contains("pie"),
true,
"pie class is present on poll div"
);
assert.equal(
queryAll(".poll-results-chart", poll).length,
1,
"Renders the chart div instead of bar container"
);
});
});