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