import React from 'react';
import { shallow } from 'enzyme';
import {
Alert,
ButtonDropdown,
Dropdown,
Tooltip,
UncontrolledAlert,
UncontrolledButtonDropdown,
UncontrolledDropdown,
UncontrolledTooltip,
} from '../';
describe('UncontrolledAlert', () => {
it('should be an Alert', () => {
const alert = shallow(Yo!);
expect(alert.type()).toBe(Alert);
});
it('should have isOpen default to true', () => {
const alert = shallow(Yo!);
expect(alert.prop('isOpen')).toBe(true);
});
it('should have toggle function', () => {
const alert = shallow(Yo!);
expect(alert.prop('toggle')).toEqual(expect.any(Function));
});
it('should toggle isOpen when toggle is called', () => {
const alert = shallow(Yo!);
const instance = alert.instance();
instance.toggle();
alert.update();
expect(alert.prop('isOpen')).toBe(false);
});
});
describe('UncontrolledButtonDropdown', () => {
it('should be an ButtonDropdown', () => {
const buttonDropdown = shallow(Yo!);
expect(buttonDropdown.type()).toBe(ButtonDropdown);
});
it('should have isOpen default to false', () => {
const buttonDropdown = shallow(Yo!);
expect(buttonDropdown.prop('isOpen')).toBe(false);
});
it('should have toggle function', () => {
const buttonDropdown = shallow(Yo!);
expect(buttonDropdown.prop('toggle')).toEqual(expect.any(Function));
});
it('should toggle isOpen when toggle is called', () => {
const buttonDropdown = shallow(Yo!);
const instance = buttonDropdown.instance();
instance.toggle();
buttonDropdown.update();
expect(buttonDropdown.prop('isOpen')).toBe(true);
});
});
describe('UncontrolledDropdown', () => {
it('should be an Dropdown', () => {
const dropdown = shallow(Yo!);
expect(dropdown.type()).toBe(Dropdown);
});
it('should have isOpen default to false', () => {
const dropdown = shallow(Yo!);
expect(dropdown.prop('isOpen')).toBe(false);
});
it('should have toggle function', () => {
const dropdown = shallow(Yo!);
expect(dropdown.prop('toggle')).toEqual(expect.any(Function));
});
it('should toggle isOpen when toggle is called', () => {
const dropdown = shallow(Yo!);
const instance = dropdown.instance();
instance.toggle();
dropdown.update();
expect(dropdown.prop('isOpen')).toBe(true);
});
});
describe('UncontrolledTooltip', () => {
it('should be an Tooltip', () => {
const tooltip = shallow(Yo!);
expect(tooltip.type()).toBe(Tooltip);
});
it('should have isOpen default to false', () => {
const tooltip = shallow(Yo!);
expect(tooltip.prop('isOpen')).toBe(false);
});
it('should have toggle function', () => {
const tooltip = shallow(Yo!);
expect(tooltip.prop('toggle')).toEqual(expect.any(Function));
});
it('should toggle isOpen when toggle is called', () => {
const tooltip = shallow(Yo!);
const instance = tooltip.instance();
instance.toggle();
tooltip.update();
expect(tooltip.prop('isOpen')).toBe(true);
});
it('should have boundary set to string', () => {
const tooltip = shallow(Yo!);
expect(tooltip.prop('boundariesElement')).toBe('window');
});
it('should render correctly with a ref object as the target', () => {
const target = React.createRef();
const tooltip = shallow(Yo!);
expect(tooltip.exists()).toBe(true);
});
});