DEV: Fix pretender in poll tests (#17587)

This commit is contained in:
Jarek Radosz 2022-07-21 10:53:21 +02:00 committed by GitHub
parent e509c54b4c
commit c700cf3213
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,35 +12,37 @@ let requests = 0;
module("Integration | Component | Widget | discourse-poll", function (hooks) { module("Integration | Component | Widget | discourse-poll", function (hooks) {
setupRenderingTest(hooks); setupRenderingTest(hooks);
pretender.put("/polls/vote", () => { hooks.beforeEach(function () {
++requests; pretender.put("/polls/vote", () => {
return [ ++requests;
200, return [
{ "Content-Type": "application/json" }, 200,
{ { "Content-Type": "application/json" },
poll: { {
name: "poll", poll: {
type: "regular", name: "poll",
status: "open", type: "regular",
results: "always", status: "open",
options: [ results: "always",
{ options: [
id: "1f972d1df351de3ce35a787c89faad29", {
html: "yes", id: "1f972d1df351de3ce35a787c89faad29",
votes: 1, html: "yes",
}, votes: 1,
{ },
id: "d7ebc3a9beea2e680815a1e4f57d6db6", {
html: "no", id: "d7ebc3a9beea2e680815a1e4f57d6db6",
votes: 0, html: "no",
}, votes: 0,
], },
voters: 1, ],
chart_type: "bar", voters: 1,
chart_type: "bar",
},
vote: ["1f972d1df351de3ce35a787c89faad29"],
}, },
vote: ["1f972d1df351de3ce35a787c89faad29"], ];
}, });
];
}); });
const template = hbs` const template = hbs`
@ -160,13 +162,10 @@ module("Integration | Component | Widget | discourse-poll", function (hooks) {
}); });
await render(template); await render(template);
assert.ok(exists(".poll-buttons .cast-votes[disabled=true]")); assert.ok(exists(".poll-buttons .cast-votes[disabled=true]"));
await click("li[data-poll-option-id='1f972d1df351de3ce35a787c89faad29']"); await click("li[data-poll-option-id='1f972d1df351de3ce35a787c89faad29']");
await click(".poll-buttons .cast-votes"); await click(".poll-buttons .cast-votes");
assert.ok(exists(".chosen")); assert.ok(exists(".chosen"));
}); });
}); });