mirror of
https://github.com/GSA/notifications-admin.git
synced 2026-02-23 11:51:05 -05:00
Add tests for 'dialog' mode
'dialog' mode was introduced as part of this work: https://github.com/alphagov/notifications-admin/pull/2682 It lets multiple elements sticky to the viewport together so a set of UI can be present for a set scrolling range. It's called a 'dialog' because the behaviour is closest to that of a modal dialog.
This commit is contained in:
@@ -86,6 +86,39 @@ const triggerEvent = (el, evtType, options) => {
|
||||
el.dispatchEvent(evt);
|
||||
};
|
||||
|
||||
function getRadios (fields) {
|
||||
const result = '';
|
||||
|
||||
return fields.map((field, idx) => {
|
||||
const count = idx + 1;
|
||||
|
||||
return `
|
||||
<div class="multiple-choice">
|
||||
<input id="choose-${field.name}-1" name="choose-${field.name}-1" type="radio" value="${field.value}" ${field.checked ? 'checked' : ''}>
|
||||
<label class="block-label" for="choose-${field.name}-1">
|
||||
${field.label}
|
||||
</label>
|
||||
</div>`;
|
||||
}).join("\n");
|
||||
};
|
||||
|
||||
function getRadioGroup (data) {
|
||||
let radioGroup = document.createElement('div');
|
||||
|
||||
data.cssClasses.forEach(cssClass => radioGroup.classList.add(cssClass));
|
||||
radioGroup.innerHTML = `
|
||||
<div class="form-group ">
|
||||
<fieldset id="choose-${data.name}">
|
||||
<legend class="form-label">
|
||||
Choose ${data.label}
|
||||
</legend>
|
||||
${getRadios(data.fields)}
|
||||
</fieldset>
|
||||
</div>`;
|
||||
|
||||
return radioGroup;
|
||||
};
|
||||
|
||||
function clickElementWithMouse (el) {
|
||||
triggerEvent(el, 'mousedown');
|
||||
triggerEvent(el, 'mouseup');
|
||||
@@ -483,6 +516,8 @@ exports.moveSelectionToRadio = moveSelectionToRadio;
|
||||
exports.activateRadioWithSpace = activateRadioWithSpace;
|
||||
exports.RangeMock = RangeMock;
|
||||
exports.SelectionMock = SelectionMock;
|
||||
exports.getRadioGroup = getRadioGroup;
|
||||
exports.getRadios = getRadios;
|
||||
exports.element = element;
|
||||
exports.WindowMock = WindowMock;
|
||||
exports.ScreenMock = ScreenMock;
|
||||
|
||||
Reference in New Issue
Block a user