Skip to content

Commit

Permalink
Fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandraRamanenka committed May 16, 2024
1 parent f89b57e commit 75f460a
Showing 1 changed file with 32 additions and 12 deletions.
44 changes: 32 additions & 12 deletions src/Webform.unit.js
Original file line number Diff line number Diff line change
Expand Up @@ -4835,20 +4835,40 @@ describe('Webform tests', function() {
const select = form.getComponent('select');
const radio = form.getComponent('radio');

selectBoxes.setValue({ AL: false, AK: true, AS: true }, { modified: true });
select.setValue('AL', { modified: true });
radio.setValue('AL', { modified: true });
selectBoxes.componentModal.openModal();
select.componentModal.openModal();
radio.componentModal.openModal();

setTimeout(() => {
const previewSelectBoxes = selectBoxes.element.querySelector('[ref="openModal"]');
const previewSelect = select.element.querySelector('[ref="openModal"]');
const previewRadio = radio.element.querySelector('[ref="openModal"]');
assert.equal(previewSelectBoxes.innerHTML, '\n <span>Alaska</span>, <span>American Samoa</span>\n');
assert.equal(previewSelect.innerHTML, '\n <span>Alabama</span>\n');
assert.equal(previewSelectBoxes.innerHTML, '\n <span>Alabama</span>\n');

Formio.makeRequest = originalMakeRequest;
done();
form.setSubmission({
data: {
selectBoxes: { AL: false, AK: true, AS: true },
select: 'AL',
radio: 'AL',
}
});

setTimeout(() => {
selectBoxes.componentModal.closeModal();
select.componentModal.closeModal();
radio.componentModal.closeModal();

setTimeout(() => {
const previewSelectBoxes = selectBoxes.element.querySelector('[ref="openModal"]');
const previewSelect = select.element.querySelector('[ref="openModal"]');
const previewRadio = radio.element.querySelector('[ref="openModal"]');

assert.equal(previewSelectBoxes.innerHTML, '\n <span>Alaska</span>, <span>American Samoa</span>\n', 'Should show labels as a selected value' +
' for SelectBoxes component');
assert.equal(previewRadio.innerHTML, '\n <span>Alabama</span>\n', 'Should show label as a selected value' +
' for Radio component');
assert.equal(previewSelect.innerHTML, '\n <span>Alabama</span>\n', 'Should show label as a selected value' +
' for Select component');

Formio.makeRequest = originalMakeRequest;
done();
}, 300);
}, 300);
}, 300);
})
.catch((err) => done(err));
Expand Down

0 comments on commit 75f460a

Please sign in to comment.