discourse/plugins/poll/test/javascripts/acceptance/polls-test-mobile.js.es6
2019-02-27 19:16:24 +01:00

54 lines
1.3 KiB
JavaScript

import { acceptance } from "helpers/qunit-helpers";
import { clearPopupMenuOptionsCallback } from "discourse/controllers/composer";
acceptance("Rendering polls - mobile", {
loggedIn: true,
mobileView: true,
settings: { poll_enabled: true },
beforeEach() {
clearPopupMenuOptionsCallback();
}
});
test("Public number poll", async assert => {
await visit("/t/-/13");
const polls = find(".poll");
assert.equal(polls.length, 1, "it should render the poll correctly");
await click("button.toggle-results");
assert.equal(
find(".poll-voters:first li").length,
25,
"it should display the right number of voters"
);
assert.ok(
find(".poll-voters:first li:first a").attr("href"),
"user URL exists"
);
// eslint-disable-next-line
server.get("/polls/voters.json", () => {
const body = {
voters: Array.from(new Array(10), (_, i) => ({
id: 500 + i,
username: `bruce${500 + i}`,
avatar_template: "/images/avatar.png",
name: "Bruce Wayne"
}))
};
return [200, { "Content-Type": "application/json" }, body];
});
await click(".poll-voters-toggle-expand:first a");
assert.equal(
find(".poll-voters:first li").length,
35,
"it should display the right number of voters"
);
});