Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
test('it renders', async function(assert) {
this.render(hbs`{{foo-bar}}`);
await triggerEvent('.foo', 'change');
await triggerEvent('.foo', 'submit');
await triggerEvent('.foo', 'focusin');
await triggerEvent('.foo', 'focusout');
await triggerEvent('.foo', 'mousedown');
await triggerEvent('.foo', 'mouseenter');
await triggerEvent('.foo', 'mouseleave');
await triggerEvent('.foo', 'mousemove');
await triggerEvent('.foo', 'mouseout');
await triggerEvent('.foo', 'mouseover');
await triggerEvent('.foo', 'mouseup');
await triggerEvent('.foo', 'input');
await click('.foo');
assert.ok(true);
});
test('it renders', async function(assert) {
this.render(hbs`{{foo-bar}}`);
await triggerEvent('.foo', 'change');
await triggerEvent('.foo', 'submit');
await triggerEvent('.foo', 'focusin');
await triggerEvent('.foo', 'focusout');
await triggerEvent('.foo', 'mousedown');
await triggerEvent('.foo', 'mouseenter');
await triggerEvent('.foo', 'mouseleave');
await triggerEvent('.foo', 'mousemove');
await triggerEvent('.foo', 'mouseout');
await triggerEvent('.foo', 'mouseover');
await triggerEvent('.foo', 'mouseup');
await triggerEvent('.foo', 'input');
await click('.foo');
assert.ok(true);
});
export async function drag(dragSelector, options = {}) {
let dragEvent = new MockEvent(options.dragStartOptions);
await triggerEvent(dragSelector, 'mouseover');
await triggerEvent(dragSelector, 'dragstart', dragEvent);
if (options.afterDrag) {
await options.afterDrag.call();
}
if (options.drop) {
await drop(dragSelector, dragEvent, options);
}
}
export async function dragAndDrop(selector, ...files) {
let dropzone = find(selector);
assert(`Selector '${dropzone}' could not be found.`, dropzone);
assert(
'All files must be instances of File/Blob type',
files.every((file) => file instanceof Blob)
);
let dataTransfer = { files };
await triggerEvent(dropzone, 'dragenter', { dataTransfer });
await triggerEvent(dropzone, 'dragover', { dataTransfer });
return triggerEvent(dropzone, 'drop', { dataTransfer });
}
export async function dragAndDrop(fieldSelector, dropZoneSelector, options) {
await triggerEvent(fieldSelector, 'mousedown');
await triggerEvent(fieldSelector, 'dragstart', options);
await triggerEvent(dropZoneSelector, 'drop', options);
}
export async function fillContentEditable(selector, content) {
click(selector);
$(selector).html(content);
triggerEvent(selector, 'keyup', 13);
triggerEvent(selector, 'blur');
}
export async function nativeTouch(selectorOrDomElement) {
triggerEvent(selectorOrDomElement, 'touchstart');
return triggerEvent(selectorOrDomElement, 'touchend');
}
async function dragOver(dropSelector, moves) {
moves = moves || [[{ clientX: 1, clientY: 1 }, dropSelector]];
for (const move of moves) {
const position = move[0] || false;
const selector = move[1] || false;
const event = new MockEvent(position);
await triggerEvent(selector || dropSelector, 'dragover', event);
}
}
export async function setCardId(id) {
await showCardId();
await fillIn('#card__id', id);
await triggerEvent('#card__id', 'keyup');
}
export async function selectDate(date) {
const day = date.getDate();
const month = date.getMonth();
const year = date.getFullYear();
const selectEvent = 'ontouchend' in document ? 'touchend' : 'mousedown';
const yearElement = findVisibleElement(YEAR_SELECTOR);
yearElement.value = year;
await triggerEvent(yearElement, 'change');
const monthElement = findVisibleElement(MONTH_SELECTOR);
monthElement.value = month;
await triggerEvent(monthElement, 'change');
await triggerEvent(
findVisibleElement(
'td[data-day="' + day + '"]:not(.is-outside-current-month) button'
),
selectEvent
);
}