All files / menu/__tests__ Menu-test.js

100% Statements 19/19
100% Branches 0/0
85.71% Functions 6/7
100% Lines 19/19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41    1x 1x 1x 1x       1x 1x 1x 1x     1x 1x     1x     1x 1x     1x     1x   1x 1x   1x     1x      
/* global describe, it */
 
import assert from 'assert'
import React from 'react'
import {Menu} from '../'
import {mount} from 'enzyme'
 
function noop () {}
 
describe('Menu', () => {
  it('should work', () => {
    const wrapper = mount(<Menu onClick={noop} />)
    assert.equal(wrapper.find('.Menu').length, 1)
  })
 
  it('should use initial items', () => {
    const wrapper = mount(
      <Menu onClick={noop} visible items={['Dog', 'Cat', 'Mouse']} />
    )
    assert.equal(wrapper.find('.Menu').text(), 'DogCatMouse')
  })
 
  it('should render the list closed', () => {
    const wrapper = mount(
      <Menu onClick={noop} items={['Dog', 'Cat', 'Mouse']} />
    )
    assert.equal(wrapper.find('.Menu-list').length, 0)
  })
 
  it('should notify on item click', (done) => {
    function onClick (animal) {
      assert.equal(animal, 'Cat')
      done()
    }
    const wrapper = mount(
      <Menu onClick={onClick} visible items={['Dog', 'Cat', 'Mouse']} />
    )
    wrapper.find('.Menu-list-item-link').at(1).simulate('click')
  })
})