All files / snackbar/__tests__ Snackbar-test.js

100% Statements 22/22
100% Branches 0/0
100% Functions 7/7
100% Lines 21/21
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    1x 1x 1x 1x   1x 1x 1x 1x     1x 1x 1x     1x 1x 1x     1x 1x 1x 1x     1x 1x 1x      
/* global it, describe */
 
import assert from 'assert'
import React from 'react'
import Snackbar from '../'
import {mount} from 'enzyme'
 
describe('Snackbar', () => {
  it('should be empty by default', () => {
    const wrapper = mount(<Snackbar visible />)
    assert.equal(wrapper.find('.Snackbar').text(), '')
  })
 
  it('should render with text', () => {
    const wrapper = mount(<Snackbar visible text='all good' />)
    assert.equal(wrapper.find('.Snackbar').text(), 'all good')
  })
 
  it('should render with text and action button', () => {
    const wrapper = mount(<Snackbar visible text='all good' action='undo' />)
    assert.equal(wrapper.find('.Snackbar-action').node.value, 'undo')
  })
 
  it('should trigger an event when clicking on action button', (done) => {
    const callback = () => done()
    const wrapper = mount(<Snackbar visible text='all good' action='undo' onAction={callback} />)
    wrapper.find('.Snackbar-action').simulate('click')
  })
 
  it('should be hidden by default', () => {
    const wrapper = mount(<Snackbar />)
    assert.equal(wrapper.find('.Snackbar').length, 0)
  })
})