ldx-widgets
Version:
widgets
68 lines (37 loc) • 2 kB
text/coffeescript
describe 'DatePicker', ->
React = require 'react'
DatePicker = React.createFactory require('../../src/components/date_picker')
TestUtils = require 'react-addons-test-utils'
ReactDOM = require 'react-dom'
dispatcher = require('../../src/dispatcher')
Spinner = React.createFactory require('../../src/components/spinner')
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', ->
datePicker = TestUtils.renderIntoDocument DatePicker {}
defaultProps = datePicker.props
expect(defaultProps.placeholderText).to.equal('Select a date')
expect(defaultProps.dateFormat).to.equal('MM/DD/YYYY')
expect(defaultProps.dateFormat).to.be.a('string')
expect(defaultProps.includeTime).to.equal(no)
expect(defaultProps.onChange).to.be.a('function')
it 'Expects tabIndex to be a number if tabIndex is passed', ->
datePicker = TestUtils.renderIntoDocument DatePicker {
tabIndex: 1
}
expect(typeof datePicker.props.tabIndex).to.equal('number')
#--------------------------------------------------------------------- CSS Classes
it 'Should Render the appropriate CSS class when className is passed', ->
className = 'new-class'
datePicker = TestUtils.renderIntoDocument DatePicker {
className: className
}
newClassName = TestUtils.scryRenderedDOMComponentsWithClass datePicker, className
expect(newClassName.length).to.equal(1)