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 toggle isOpen', (done) => {
const wrapper = renderIntoContainer(
Tooltip Content
, container
);
wrapper.forceUpdate(() => {
expect(document.getElementsByClassName('tooltip').length).toBe(0);
setProps(wrapper, { isOpen: true });
expect(document.getElementsByClassName('tooltip').length).toBe(1);
setProps(wrapper, { isOpen: false });
expect(document.getElementsByClassName('tooltip').length).toBe(0);
done();
});
});
it('should render with "hideArrow" true when "hideArrow" prop is truthy', () => {
const wrapper = renderIntoContainer(
Tooltip Content
, container
);
expect(wrapper.props['hideArrow']).toBe(true);
});
it('should render with class "modal-dialog" and have custom class name if provided', (done) => {
isOpen = true;
const renderedTree = renderIntoContainer(Yo!, container);
renderedTree.forceUpdate(() => {
expect(container.innerHTML).toBe('');
expect(document.getElementsByClassName('my-custom-modal').length).toBe(1);
expect(document.getElementsByClassName('modal-dialog').length).toBe(1);
done()
})
});
it('should render with target object', (done) => {
isOpen = true;
const wrapper = renderIntoContainer(
Tooltip Content
, container
);
wrapper.forceUpdate(() => {
const tooltips = document.getElementsByClassName('tooltip');
expect(container.querySelector('.tooltip.show')).toBeDefined();
expect(tooltips.length).toBe(1);
expect(tooltips[0].textContent).toBe('Tooltip Content');
done();
});
});
it('should handle target clicks', () => {
const wrapper = renderIntoContainer(
Tooltip Content
, container
);
expect(isOpen).toBe(false);
triggerEvent('click', target)
expect(isOpen).toBe(true);
triggerEvent('click', target)
expect(isOpen).toBe(false);
});
it('should render a Manager as a span by default', () => {
const renderedTree = renderIntoContainer(Yo!, container);
const node = findVNodeWithType(renderedTree, Manager)
expect(node).toBeDefined()
});
it('should have default isOpen value', () => {
const renderTree = renderIntoContainer();
expect(renderTree.props.isOpen).toEqual(false);
});