All files / chip/__tests__ Chip-test.js

100% Statements 19/19
100% Branches 0/0
100% Functions 5/5
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 42 43 44 45 46 47 48 49 50 51 52 53 54    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 {mount} from 'enzyme'
import Chip from '../'
 
describe('Chip', () => {
  it('should render an input field', () => {
    const wrapper = mount(<Chip />)
    assert.equal(wrapper.find('.Chip-input').length, 1)
  })
 
  it('should be empty by default', () => {
    const wrapper = mount(<Chip />)
    assert.equal(wrapper.find('.Chip').length, 0)
  })
 
  it('should accept initial chips as property', () => {
    const wrapper = mount(<Chip initialValues={['one', 'two']} />)
    assert.equal(wrapper.find('.Chip').length, 2)
  })
 
  it('should add a chip on enter', () => {
    const wrapper = mount(<Chip initialValues={[]} />)
    wrapper.find('input').simulate('change', {
      target: {
        value: 'hello'
      }
    })
    // make sure input has new value / state
    assert.equal(wrapper.find('input').node.value, 'hello')
    wrapper.find('input').simulate('keypress', {
      which: 13
    })
  })
 
  // it('should not add a chip when input field is empty', () => {
  //
  // })
 
  // it('should call back when chip is added', () => {
  //
  // })
 
  // it('should focus the last chip when left arrow is pressed inside input the field', () => {
 
  // })
 
  // it('should focus the first chip when right arrow is pressed inside the input field', () => {
 
  // })
})