|
| 1 | +import React from 'react'; |
| 2 | +import { shallow } from 'enzyme'; |
| 3 | +import Alert from '../Alert'; |
| 4 | +import ButtonDropdown from '../ButtonDropdown'; |
| 5 | +import Dropdown from '../Dropdown'; |
| 6 | +import NavDropdown from '../NavDropdown'; |
| 7 | +import Tooltip from '../Tooltip'; |
| 8 | +import { |
| 9 | + UncontrolledAlert, |
| 10 | + UncontrolledButtonDropdown, |
| 11 | + UncontrolledDropdown, |
| 12 | + UncontrolledNavDropdown, |
| 13 | + UncontrolledTooltip, |
| 14 | +} from '../Uncontrolled'; |
| 15 | + |
| 16 | +describe('UncontrolledAlert', () => { |
| 17 | + it('should be an Alert', () => { |
| 18 | + const alert = shallow(<UncontrolledAlert>Yo!</UncontrolledAlert>); |
| 19 | + expect(alert.type()).toBe(Alert); |
| 20 | + }); |
| 21 | + |
| 22 | + it('should have isOpen default to true', () => { |
| 23 | + const alert = shallow(<UncontrolledAlert>Yo!</UncontrolledAlert>); |
| 24 | + expect(alert.prop('isOpen')).toBe(true); |
| 25 | + }); |
| 26 | + |
| 27 | + it('should have toggle function', () => { |
| 28 | + const alert = shallow(<UncontrolledAlert>Yo!</UncontrolledAlert>); |
| 29 | + expect(alert.prop('toggle')).toEqual(jasmine.any(Function)); |
| 30 | + }); |
| 31 | + |
| 32 | + it('should toggle isOpen when toggle is called', () => { |
| 33 | + const alert = shallow(<UncontrolledAlert>Yo!</UncontrolledAlert>); |
| 34 | + const instance = alert.instance(); |
| 35 | + instance.toggle(); |
| 36 | + expect(alert.prop('isOpen')).toBe(false); |
| 37 | + }); |
| 38 | +}); |
| 39 | + |
| 40 | +describe('UncontrolledButtonDropdown', () => { |
| 41 | + it('should be an ButtonDropdown', () => { |
| 42 | + const buttonDropdown = shallow(<UncontrolledButtonDropdown>Yo!</UncontrolledButtonDropdown>); |
| 43 | + expect(buttonDropdown.type()).toBe(ButtonDropdown); |
| 44 | + }); |
| 45 | + |
| 46 | + it('should have isOpen default to false', () => { |
| 47 | + const buttonDropdown = shallow(<UncontrolledButtonDropdown>Yo!</UncontrolledButtonDropdown>); |
| 48 | + expect(buttonDropdown.prop('isOpen')).toBe(false); |
| 49 | + }); |
| 50 | + |
| 51 | + it('should have toggle function', () => { |
| 52 | + const buttonDropdown = shallow(<UncontrolledButtonDropdown>Yo!</UncontrolledButtonDropdown>); |
| 53 | + expect(buttonDropdown.prop('toggle')).toEqual(jasmine.any(Function)); |
| 54 | + }); |
| 55 | + |
| 56 | + it('should toggle isOpen when toggle is called', () => { |
| 57 | + const buttonDropdown = shallow(<UncontrolledButtonDropdown>Yo!</UncontrolledButtonDropdown>); |
| 58 | + const instance = buttonDropdown.instance(); |
| 59 | + instance.toggle(); |
| 60 | + expect(buttonDropdown.prop('isOpen')).toBe(true); |
| 61 | + }); |
| 62 | +}); |
| 63 | + |
| 64 | +describe('UncontrolledDropdown', () => { |
| 65 | + it('should be an Dropdown', () => { |
| 66 | + const dropdown = shallow(<UncontrolledDropdown>Yo!</UncontrolledDropdown>); |
| 67 | + expect(dropdown.type()).toBe(Dropdown); |
| 68 | + }); |
| 69 | + |
| 70 | + it('should have isOpen default to false', () => { |
| 71 | + const dropdown = shallow(<UncontrolledDropdown>Yo!</UncontrolledDropdown>); |
| 72 | + expect(dropdown.prop('isOpen')).toBe(false); |
| 73 | + }); |
| 74 | + |
| 75 | + it('should have toggle function', () => { |
| 76 | + const dropdown = shallow(<UncontrolledDropdown>Yo!</UncontrolledDropdown>); |
| 77 | + expect(dropdown.prop('toggle')).toEqual(jasmine.any(Function)); |
| 78 | + }); |
| 79 | + |
| 80 | + it('should toggle isOpen when toggle is called', () => { |
| 81 | + const dropdown = shallow(<UncontrolledDropdown>Yo!</UncontrolledDropdown>); |
| 82 | + const instance = dropdown.instance(); |
| 83 | + instance.toggle(); |
| 84 | + expect(dropdown.prop('isOpen')).toBe(true); |
| 85 | + }); |
| 86 | +}); |
| 87 | + |
| 88 | +describe('UncontrolledNavDropdown', () => { |
| 89 | + it('should be an NavDropdown', () => { |
| 90 | + const navDropdown = shallow(<UncontrolledNavDropdown>Yo!</UncontrolledNavDropdown>); |
| 91 | + expect(navDropdown.type()).toBe(NavDropdown); |
| 92 | + }); |
| 93 | + |
| 94 | + it('should have isOpen default to false', () => { |
| 95 | + const navDropdown = shallow(<UncontrolledNavDropdown>Yo!</UncontrolledNavDropdown>); |
| 96 | + expect(navDropdown.prop('isOpen')).toBe(false); |
| 97 | + }); |
| 98 | + |
| 99 | + it('should have toggle function', () => { |
| 100 | + const navDropdown = shallow(<UncontrolledNavDropdown>Yo!</UncontrolledNavDropdown>); |
| 101 | + expect(navDropdown.prop('toggle')).toEqual(jasmine.any(Function)); |
| 102 | + }); |
| 103 | + |
| 104 | + it('should toggle isOpen when toggle is called', () => { |
| 105 | + const navDropdown = shallow(<UncontrolledNavDropdown>Yo!</UncontrolledNavDropdown>); |
| 106 | + const instance = navDropdown.instance(); |
| 107 | + instance.toggle(); |
| 108 | + expect(navDropdown.prop('isOpen')).toBe(true); |
| 109 | + }); |
| 110 | +}); |
| 111 | + |
| 112 | +describe('UncontrolledTooltip', () => { |
| 113 | + it('should be an Tooltip', () => { |
| 114 | + const tooltip = shallow(<UncontrolledTooltip target="blah">Yo!</UncontrolledTooltip>); |
| 115 | + expect(tooltip.type()).toBe(Tooltip); |
| 116 | + }); |
| 117 | + |
| 118 | + it('should have isOpen default to false', () => { |
| 119 | + const tooltip = shallow(<UncontrolledTooltip target="blah">Yo!</UncontrolledTooltip>); |
| 120 | + expect(tooltip.prop('isOpen')).toBe(false); |
| 121 | + }); |
| 122 | + |
| 123 | + it('should have toggle function', () => { |
| 124 | + const tooltip = shallow(<UncontrolledTooltip target="blah">Yo!</UncontrolledTooltip>); |
| 125 | + expect(tooltip.prop('toggle')).toEqual(jasmine.any(Function)); |
| 126 | + }); |
| 127 | + |
| 128 | + it('should toggle isOpen when toggle is called', () => { |
| 129 | + const tooltip = shallow(<UncontrolledTooltip target="blah">Yo!</UncontrolledTooltip>); |
| 130 | + const instance = tooltip.instance(); |
| 131 | + instance.toggle(); |
| 132 | + expect(tooltip.prop('isOpen')).toBe(true); |
| 133 | + }); |
| 134 | +}); |
0 commit comments