All files / navigation/__tests__ Navigation-test.js

100% Statements 14/14
100% Branches 0/0
100% Functions 4/4
100% Lines 14/14
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    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 Navigation from '../'
import {mount, shallow} from 'enzyme'
 
describe('Navigation', () => {
  it('should work', () => {
    const wrapper = shallow(<Navigation links={[]} />)
    assert(wrapper.find('nav'))
  })
 
  it('should propagate changes up to its parent component on mount', (done) => {
    var items = [
      {text: 'one', link: 'one'},
      {text: 'two', link: 'two'}
    ]
    // we get the onChange event automatically on mount
    const onChange = (link) => {
      assert.equal(link.text, 'one')
      done()
    }
    mount(<Navigation links={items} onChange={onChange} />)
  })
})