import test from 'ava'
import React from 'react'
import { shallow, render } from 'enzyme'
import PanelHeader from '../src/PanelHeader'
import * as PanelTypes from '../src/PanelTypes'

const REACT_PANEL_HEADER_OPEN = 'react-panel-header-open'

test('Class react-panel-header-open on panel opened', t => {
  const wrapper = shallow(<PanelHeader isOpen panelTitle='The best panel' panelType={PanelTypes.INFO} togglePanel={() => {}} />)
  t.true(wrapper.hasClass(REACT_PANEL_HEADER_OPEN))
})

test('Remove class react-panel-header-open on panel closed', t => {
  const wrapper = shallow(<PanelHeader isOpen={false} panelTitle='The best panel' panelType={PanelTypes.INFO} togglePanel={() => {}} />)
  t.false(wrapper.hasClass(REACT_PANEL_HEADER_OPEN))
})

test('Add react-panel-success when pass the sucess type', t => {
  const wrapper = shallow(<PanelHeader isOpen={false} panelTitle='The best panel' panelType={PanelTypes.SUCCESS} togglePanel={() => {}} />)
  t.true(wrapper.hasClass('react-panel-success'))
})

test('Add react-panel-warning when pass the sucess type', t => {
  const wrapper = shallow(<PanelHeader isOpen={false} panelTitle='The best panel' panelType={PanelTypes.WARNING} togglePanel={() => {}} />)
  t.true(wrapper.hasClass('react-panel-warning'))
})

test('Add react-panel-danger when pass the sucess type', t => {
  const wrapper = shallow(<PanelHeader isOpen={false} panelTitle='The best panel' panelType={PanelTypes.DANGER} togglePanel={() => {}} />)
  t.true(wrapper.hasClass('react-panel-danger'))
})

test('Add react-panel-info when pass the sucess type', t => {
  const wrapper = shallow(<PanelHeader isOpen={false} panelTitle='The best panel' panelType={PanelTypes.INFO} togglePanel={() => {}} />)
  t.true(wrapper.hasClass('react-panel-info'))
})

test('Add react-panel-disabled when pass the sucess type', t => {
  const wrapper = shallow(<PanelHeader isOpen={false} panelTitle='The best panel' panelType={PanelTypes.DISABLED} togglePanel={() => {}} />)
  t.true(wrapper.hasClass('react-panel-disabled'))
})

// test('Return close title in options when the panel is open', t => {
//   const wrapper = render(<PanelHeader isOpen panelTitle='The best panel' panelType={PanelTypes.DISABLED} togglePanel={() => {}} />)
//   t.is('close', wrapper.find('span'))
// })

@@ -62,16 +62,8 @@
 llow
-, render
  %7D f
@@ -75,16 +75,42 @@
 enzyme'%0A
+import sinon from 'sinon'%0A
 import P
@@ -2052,82 +2052,408 @@
 %7D)%0A%0A
-// 
 test('
-Return close title in options when the panel is open', t =%3E %7B%0A// 
+Call the callback when click on span (panel title)', t =%3E %7B%0A  const mockOnClick = sinon.spy()%0A  const wrapper = shallow(%3CPanelHeader isOpen panelTitle='The best panel' panelType=%7BPanelTypes.DISABLED%7D togglePanel=%7BmockOnClick%7D /%3E)%0A  wrapper.find('span').simulate('click')%0A  t.true(mockOnClick.calledOnce)%0A%7D)%0A%0Atest('Call the callback when click on icon', t =%3E %7B%0A  const mockOnClick = sinon.spy()%0A
   co
@@ -2470,14 +2470,15 @@
 r = 
-render
+shallow
 (%3CPa
@@ -2571,65 +2571,95 @@
 el=%7B
-() =%3E %7B%7D%7D /%3E)%0A//   t.is('close', wrapper.find('span'))%0A// 
+mockOnClick%7D /%3E)%0A  wrapper.find('a').simulate('click')%0A  t.true(mockOnClick.calledOnce)%0A
 %7D)%0A

add more tests