2024-07-04 19:34:48 +08:00
|
|
|
import { render } from "@ember/test-helpers";
|
|
|
|
import hbs from "htmlbars-inline-precompile";
|
2024-07-08 19:58:35 +08:00
|
|
|
import { module, test } from "qunit";
|
2024-07-04 19:34:48 +08:00
|
|
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
|
|
|
import { count } from "discourse/tests/helpers/qunit-helpers";
|
|
|
|
|
|
|
|
const OPTIONS = [
|
|
|
|
{ id: "1ddc47be0d2315b9711ee8526ca9d83f", html: "This", votes: 3, rank: 0 },
|
|
|
|
{ id: "70e743697dac09483d7b824eaadb91e1", html: "That", votes: 1, rank: 0 },
|
|
|
|
{ id: "6c986ebcde3d5822a6e91a695c388094", html: "Other", votes: 2, rank: 0 },
|
|
|
|
];
|
|
|
|
|
|
|
|
const ID = "23";
|
|
|
|
|
|
|
|
module("Poll | Component | poll-results-pie", function (hooks) {
|
|
|
|
setupRenderingTest(hooks);
|
|
|
|
|
2024-07-08 19:58:35 +08:00
|
|
|
test("Renders the pie chart Component correctly", async function (assert) {
|
2024-07-04 19:34:48 +08:00
|
|
|
this.setProperties({
|
|
|
|
id: ID,
|
|
|
|
options: OPTIONS,
|
|
|
|
});
|
|
|
|
|
|
|
|
await render(
|
|
|
|
hbs`<PollResultsPie @id={{this.id}} @options={{this.options}} />`
|
|
|
|
);
|
|
|
|
|
|
|
|
assert.strictEqual(count("li.legend"), 3);
|
|
|
|
|
|
|
|
assert.strictEqual(count("canvas.poll-results-canvas"), 1);
|
|
|
|
});
|
|
|
|
});
|