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

21 lines
731 B
JavaScript
Raw Normal View History

import Ember from 'ember';
export default Ember.Test.registerAsyncHelper('pollParticipate', function(app, name, selections) {
if (!Ember.isEmpty(name)) {
fillIn('.participation input#Name', name);
}
2016-01-28 11:27:00 +01:00
const isFreeText = find('.participation .selections .radio').length ? false : true;
selections.forEach((selection, index) => {
if (!Ember.isEmpty(selection)) {
if (isFreeText) {
fillIn('.participation .selections .form-group:nth-child(' + (index + 1) + ') input', selection);
} else {
click('.participation .selections .form-group:nth-child(' + (index + 1) + ') input[type="radio"][value="' + selection + '"]');
}
}
});
click('.participation button[type="submit"]');
});