decide.nolog.cz/tests/helpers/poll-participate.js

32 lines
855 B
JavaScript
Raw Normal View History

2018-12-29 01:27:37 +01:00
import { isEmpty } from '@ember/utils';
import { findAll, fillIn, click } from '@ember/test-helpers';
export default async function (name, selections) {
2018-12-29 01:27:37 +01:00
if (!isEmpty(name)) {
2018-12-29 20:35:04 +01:00
await fillIn('.participation .name input', name);
}
const isFreeText =
findAll('.participation .selections .radio').length > 0 ? false : true;
2018-12-29 20:35:04 +01:00
for (let [index, selection] of selections.entries()) {
2018-12-29 01:27:37 +01:00
if (!isEmpty(selection)) {
if (isFreeText) {
await fillIn(
`.participation .selections .form-group:nth-child(${
index + 1
}) input`,
selection,
);
} else {
await click(
`.participation .selections .form-group:nth-child(${
index + 1
}) .${selection}.radio input`,
);
}
}
2018-12-29 20:35:04 +01:00
}
2018-12-29 20:35:04 +01:00
await click('.participation button[type="submit"]');
}