import React from 'react'
import { shallow } from 'enzyme'
import { ChevronIcon } from '../../icon/chevronIcon'
import { DropdownButton } from './index'
const defaultProps = {
onClick() {},
children:
,
}
describe('DropdownButton', () => {
it('Should not be open by default', () => {
const wrapper = shallow()
expect(wrapper.find('button').prop('aria-expanded')).toBe(false)
expect(wrapper.hasClass('kirk-dropdownButton--open')).toBe(false)
})
it('Should have the correct props & class when opened', () => {
const wrapper = shallow()
expect(wrapper.find('button').prop('aria-expanded')).toBe(true)
expect(wrapper.hasClass('kirk-dropdownButton--open')).toBe(true)
})
it('Should accept a custom className for the button', () => {
const customClassName = 'custom'
const wrapper = shallow()
expect(wrapper.hasClass(customClassName)).toBe(true)
})
it('Should have an attribute type button', () => {
const wrapper = shallow()
expect(wrapper.find('button[type="button"]')).toHaveLength(1)
})
it('Should always have the chevron icon', () => {
const wrapper = shallow()
expect(wrapper.find(ChevronIcon)).toHaveLength(1)
})
it('Should always handle the chevron icon position', () => {
const wrapper = shallow()
expect(wrapper.find(ChevronIcon)).toHaveLength(1)
expect(wrapper.find('.children')).toHaveLength(1)
expect(wrapper.find('button').childAt(0).is('.children')).toBe(true)
expect(wrapper.find('button').childAt(1).is(ChevronIcon)).toBe(true)
wrapper.setProps({ iconPosition: 'left' })
expect(wrapper.find('button').childAt(0).is(ChevronIcon)).toBe(true)
expect(wrapper.find('button').childAt(1).is('.children')).toBe(true)
})
})