describe 'FormAlertItem', ->
  React = require 'react'
  FormAlertItem = React.createFactory require('../../src/components/form_alert_item')
  TestUtils = require 'react-addons-test-utils'
  ReactDOM = require 'react-dom'
  dispatcher = require('../../src/dispatcher')
  ValidationContext = require '../../src/context_wrapper'


  afterEach -> dispatcher.dispatch 'clear-all'

  
  ###
  
  Note About ValidationContext

  The input validation uses context to gain access to the app level validation methods
  Because context is only present when the component is a child of the application, it is not present in tests
  The ValidationContext component, simply wraps the input component, and adds the validation context methods so they are present in the tests
  
  ###

  #--------------------------------------------------------------------- Default Props
  it 'Should have default props', ->

    wrapper = TestUtils.renderIntoDocument(ValidationContext {
      factory: FormAlertItem
      childProps:
        alert: {}
    })

    formAlertItem = wrapper.getInput()

    defaultProps = formAlertItem.props

    expect(defaultProps.alert).to.be.a 'object'

  #--------------------------------------------------------------------- Classes
  it 'Should Render a alert item with appropriate class when isAlert is true', ->
    
    wrapper = TestUtils.renderIntoDocument(ValidationContext {
      factory: FormAlertItem
      childProps:
        alert: {
          isAlert: yes
        }
    })

    el = TestUtils.findRenderedDOMComponentWithTag wrapper, 'li'

    expect(el.getAttribute('class')).to.equal('alert')


  it 'Should Render a remove alert button', ->
 
    wrapper = TestUtils.renderIntoDocument(ValidationContext {
      factory: FormAlertItem
      childProps:
        alert: {}
    })

    button = TestUtils.findRenderedDOMComponentWithTag wrapper, 'button'

    expect(button.getAttribute('class')).to.equal('alert-close')

