<commit_before>import React from 'react'
import {shallow} from 'enzyme'

import ButtonMenu from './ButtonMenu'
import Menu from './Menu'
import MenuItem from './MenuItem'
import Button from '../Button'
import ButtonGroup from '../ButtonGroup'
import Icon from '../Icon'

describe('tocco-ui', () => {
  describe('Menu', () => {
    describe('ButtonMenu', () => {
      test('should render a Button', () => {
        const wrapper = shallow(
          <ButtonMenu buttonProps={{icon: 'facebook'}}>
            <MenuItem>Test</MenuItem>
          </ButtonMenu>
        )

        expect(wrapper.find(Button)).to.have.length(1)
        expect(wrapper.find(MenuItem)).to.have.length(1)
      })

      test('should render a Buttongroup with default click handler', () => {
        const onClick = sinon.spy()
        const wrapper = shallow(
          <ButtonMenu onClick={onClick} buttonProps={{icon: 'facebook'}}>
            <MenuItem>Test</MenuItem>
          </ButtonMenu>
        )

        expect(wrapper.find(Button)).to.have.length(2)
        expect(wrapper.find(ButtonGroup)).to.have.length(1)
        expect(wrapper.find(MenuItem)).to.have.length(1)

        wrapper.find(Button).first().simulate('click')
        expect(onClick).to.be.calledOnce
      })

      test('should set menu open on click and call onOpen only once', () => {
        const onOpen = sinon.spy()
        const wrapper = shallow(
          <ButtonMenu buttonProps={{icon: 'facebook'}} onOpen={onOpen}>
            <MenuItem>Test</MenuItem>
          </ButtonMenu>
        )
        expect(wrapper.find(Menu)).to.have.prop('open', false)
        expect(wrapper.find(Icon)).to.have.prop('icon', 'angle-down')
        wrapper.find(Button).simulate('click')
        wrapper.update()
        expect(wrapper.find(Menu)).to.have.prop('open', true)
        expect(wrapper.find(Icon)).to.have.prop('icon', 'angle-up')
        expect(onOpen).to.be.calledOnce

        wrapper.find(Button).simulate('click')
        wrapper.update()
        expect(wrapper.find(Menu)).to.have.prop('open', false)
        expect(onOpen).to.be.calledOnce
      })
    })
  })
})
<commit_msg>chore: fix ButtonMenu tests<commit_after>import React from 'react'
import {shallow} from 'enzyme'

import ButtonMenu from './ButtonMenu'
import Menu from './Menu'
import MenuItem from './MenuItem'
import Button from '../Button'
import ButtonGroup from '../ButtonGroup'
import Icon from '../Icon'

describe('tocco-ui', () => {
  describe('Menu', () => {
    describe('ButtonMenu', () => {
      test('should render a Button', () => {
        const wrapper = shallow(
          <ButtonMenu buttonProps={{icon: 'facebook'}}>
            <MenuItem>Test</MenuItem>
          </ButtonMenu>
        )

        expect(wrapper.find(Button)).to.have.length(1)
        expect(wrapper.find(MenuItem)).to.have.length(1)
      })

      test('should render a Buttongroup with default click handler', () => {
        const onClick = sinon.spy()
        const wrapper = shallow(
          <ButtonMenu onClick={onClick} buttonProps={{icon: 'facebook'}}>
            <MenuItem>Test</MenuItem>
          </ButtonMenu>
        )

        expect(wrapper.find(Button)).to.have.length(1)
        expect(wrapper.find(ButtonGroup)).to.have.length(1)
        expect(wrapper.find(MenuItem)).to.have.length(1)

        wrapper.find(Button).first().simulate('click')
        expect(onClick).to.be.calledOnce
      })

      test('should set menu open on click and call onOpen only once', () => {
        const onOpen = sinon.spy()
        const wrapper = shallow(
          <ButtonMenu buttonProps={{icon: 'facebook'}} onOpen={onOpen}>
            <MenuItem>Test</MenuItem>
          </ButtonMenu>
        )
        expect(wrapper.find(Menu)).to.have.prop('open', false)
        expect(wrapper.find(Icon)).to.have.prop('icon', 'angle-down')
        wrapper.find(Button).simulate('click')
        wrapper.update()
        expect(wrapper.find(Menu)).to.have.prop('open', true)
        expect(wrapper.find(Icon)).to.have.prop('icon', 'angle-up')
        expect(onOpen).to.be.calledOnce

        wrapper.find(Button).simulate('click')
        wrapper.update()
        expect(wrapper.find(Menu)).to.have.prop('open', false)
        expect(onOpen).to.be.calledOnce
      })
    })
  })
})

{'fraction_non_alphanumeric': 0.16278528178854215, 'fraction_numerical': 0.002328830926874709, 'mean_word_length': 2.6336717428087986, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 39, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5991864', 'n_tokens_mistral': 1253, 'n_tokens_neox': 1240, 'n_words': 229}