describe 'ToggleButton', ->

  React = require 'react'
  ToggleButton = React.createFactory require('../../src/components/toggle_button')
  TestUtils = require 'react-addons-test-utils'
  ReactDOM = require 'react-dom'

  #--------------------------------------------------------------------- Default Props
  it 'Should have default props', ->
    toggleButton = TestUtils.renderIntoDocument ToggleButton {}

    defaultProps = toggleButton.props
    expect(defaultProps.option.disabled).to.equal(no)


  #--------------------------------------------------------------------- Render
  it 'Should Render the appropriate CSS class when useTabs property is true', ->
    useTabs = yes

    toggleButton = TestUtils.renderIntoDocument ToggleButton {
      useTabs: useTabs
      options: []
    }
  
    toggleTab = TestUtils.scryRenderedDOMComponentsWithClass toggleButton, "toggle-tab"
    toggleBtn = TestUtils.scryRenderedDOMComponentsWithClass toggleButton, "toggle-button"

    expect(toggleTab.length).to.equal(1)
    expect(toggleBtn.length).to.equal(0)


  it 'Should Render the appropriate CSS class when useTabs property is false', ->
    useTabs = no

    toggleButton = TestUtils.renderIntoDocument ToggleButton {
      useTabs: useTabs
    }
  
    toggleTab = TestUtils.scryRenderedDOMComponentsWithClass toggleButton, "toggle-tab"
    toggleBtn = TestUtils.scryRenderedDOMComponentsWithClass toggleButton, "toggle-button"

    expect(toggleTab.length).to.equal(0)
    expect(toggleBtn.length).to.equal(1)


  it 'Should Render the is-selected CSS class when selected property is true', ->
    selected = yes

    toggleButton = TestUtils.renderIntoDocument ToggleButton {
      selected: selected
    }
  
    toggleBtn = TestUtils.scryRenderedDOMComponentsWithClass toggleButton, "is-selected"
    

    expect(toggleBtn.length).to.equal(1)


  it 'Should NOT Render the is-selected CSS class when selected property is false', ->
    selected = no

    toggleButton = TestUtils.renderIntoDocument ToggleButton {
      selected: selected
    }
  
    toggleBtn = TestUtils.scryRenderedDOMComponentsWithClass toggleButton, "is-selected"
    

    expect(toggleBtn.length).to.equal(0)


  # --------------------------------------------------------------------- onClick
  it 'Should call the props.setFormData when button is clicked', ->
    setFormData = sinon.spy()

    toggleButton = TestUtils.renderIntoDocument ToggleButton {
        setFormData: setFormData
      }
    
    mainBtn = TestUtils.findRenderedDOMComponentWithTag toggleButton, 'button'

    TestUtils.Simulate.click mainBtn, {}

    expect(setFormData.called).to.equal(true)



