Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should expose fire event helpers', () => {
fireEvent.copy(htmlEl);
fireEvent.cut(htmlEl);
fireEvent.paste(htmlEl);
fireEvent.compositionEnd(htmlEl);
fireEvent.compositionStart(htmlEl);
fireEvent.compositionUpdate(htmlEl);
fireEvent.keyDown(htmlEl);
fireEvent.keyPress(htmlEl);
fireEvent.keyUp(htmlEl);
fireEvent.focus(htmlEl);
fireEvent.blur(htmlEl);
fireEvent.change(htmlEl);
fireEvent.input(htmlEl);
fireEvent.invalid(htmlEl);
fireEvent.submit(htmlEl);
fireEvent.click(htmlEl);
fireEvent.contextMenu(htmlEl);
fireEvent.dblClick(htmlEl);
fireEvent.doubleClick(htmlEl);
fireEvent.drag(htmlEl);
fireEvent.dragEnd(htmlEl);
fireEvent.dragEnter(htmlEl);
fireEvent.dragExit(htmlEl);
fireEvent.dragLeave(htmlEl);
fireEvent.dragOver(htmlEl);
fireEvent.dragStart(htmlEl);
fireEvent.drop(htmlEl);
blurOnInput: extraEventProps => fireEvent.blur(input, extraEventProps),
}
const mock = jest.fn((value: InjectedRemirrorProps) => {
setContent = value.setContent;
return <div>;
});
const { getByLabelText } = render(
{mock}
,
);
setContent(`<p>${textContent}</p>`, true);
const editorNode = getByLabelText(label);
expect(handlers.onChange).toHaveBeenCalledTimes(1);
expect(handlers.onFirstRender.mock.calls[0][0].getText()).toBe(textContent);
fireEvent.blur(editorNode);
expect(handlers.onBlur).toHaveBeenCalledTimes(1);
fireEvent.focus(editorNode);
expect(handlers.onFocus).toHaveBeenCalledTimes(1);
});
</div>
it('should call onBlur when onBlur is called for a valid date', () => {
const onBlurMock = jest.fn()
const { getByDisplayValue } = render(
)
fireEvent.blur(getByDisplayValue('2001'))
expect(onBlurMock).toHaveBeenCalledTimes(1)
expect(onBlurMock).toHaveBeenCalledWith('8/14/2001')
})
it('clears currently focused item', () => {
const { getAllByTestId } = render();
const [item] = getAllByTestId('item');
fireEvent.focus(item);
expect(item).toHaveAttribute('data-focused', 'true');
fireEvent.blur(item);
expect(item).toHaveAttribute('data-focused', 'false');
});
});
)}
/>
);
const input = getByLabelText('resources.users.fields.role');
fireEvent.focus(input);
fireEvent.change(input, { target: { value: 'a' } });
expect(queryAllByRole('option').length).toEqual(2);
fireEvent.blur(input);
fireEvent.focus(input);
fireEvent.change(input, { target: { value: 'a' } });
expect(queryAllByRole('option').length).toEqual(2);
});
});
{
longLink: 'https://github.com/short-d/short/',
alias: 'short'
}
]}
/>
);
const input = getByPlaceholderText(
'Search short links'
) as HTMLInputElement;
expect(container.querySelector('.suggestions.show')).toBeFalsy();
fireEvent.focus(input);
expect(container.querySelector('.suggestions.show')).toBeTruthy();
fireEvent.blur(input);
jest.advanceTimersByTime(TOTAL_DURATION);
expect(container.querySelector('.suggestions.show')).toBeFalsy();
});
});
<form> (
)}
/>
);
const input = queryByLabelText('Angular');
fireEvent.click(input);
expect(input.checked).toBe(true);
fireEvent.blur(input);
expect(queryByText('ra.validation.error')).not.toBeNull();
});
});</form>
allowEmpty
emptyText="Empty"
validate={required()}
/>
)}
/>
);
const input = getByLabelText('resources.posts.fields.language *');
const select = getByRole('button');
fireEvent.click(select);
const optionAngular = getByText('Angular');
fireEvent.click(optionAngular);
fireEvent.blur(input);
fireEvent.blur(select);
const optionEmpty = getByText('Empty');
fireEvent.click(optionEmpty);
fireEvent.blur(input);
fireEvent.blur(select);
const error = getByText('ra.validation.required');
expect(error).not.toBeNull();
});
});
)
const { container } = render(ui)
const dropzone = container.querySelector('div')
fireEvent.click(dropzone)
expect(rootProps.onClick).toHaveBeenCalled()
fireEvent.focus(dropzone)
fireEvent.keyDown(dropzone)
expect(rootProps.onFocus).toHaveBeenCalled()
expect(rootProps.onKeyDown).toHaveBeenCalled()
fireEvent.blur(dropzone)
expect(rootProps.onBlur).toHaveBeenCalled()
fireEvent.dragEnter(dropzone, event)
expect(rootProps.onDragEnter).toHaveBeenCalled()
fireEvent.dragOver(dropzone, event)
expect(rootProps.onDragOver).toHaveBeenCalled()
fireEvent.dragLeave(dropzone, event)
expect(rootProps.onDragLeave).toHaveBeenCalled()
fireEvent.drop(dropzone, event)
expect(rootProps.onDrop).toHaveBeenCalled()
})