decide.nolog.cz/tests/helpers/poll-participate.js
2018-12-31 10:17:03 +01:00

21 lines
750 B
JavaScript

import { isEmpty } from '@ember/utils';
import { findAll, fillIn, click } from '@ember/test-helpers';
export default async function(name, selections) {
if (!isEmpty(name)) {
await fillIn('.participation .name input', name);
}
const isFreeText = findAll('.participation .selections .radio').length > 0 ? false : true;
for (let [index, selection] of selections.entries()) {
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`);
}
}
}
await click('.participation button[type="submit"]');
}