UNPKG

ldx-widgets

Version:

widgets

75 lines (43 loc) 2.27 kB
describe 'ProgressBar', -> React = require 'react' ProgressBar = React.createFactory require('../../src/components/progress_bar') TestUtils = require 'react-addons-test-utils' ReactDOM = require 'react-dom' #--------------------------------------------------------------------- Default Props it 'Should have default props', -> progressBar = TestUtils.renderIntoDocument ProgressBar {} defaultProps = progressBar.props expect(defaultProps.progress).to.equal(0) expect(defaultProps.showLabel).to.equal(true) expect(defaultProps.indeterminate).to.equal(false) #--------------------------------------------------------------------- Render it 'Should Render progress label if showLabel property is true', -> progressBar = TestUtils.renderIntoDocument ProgressBar {} labelDiv = TestUtils.scryRenderedDOMComponentsWithClass progressBar, 'progress-label' expect(labelDiv.length).to.equal(1) it 'Should NOT Render progress label if showLabel property is false', -> progressBar = TestUtils.renderIntoDocument ProgressBar { showLabel: no } labelDiv = TestUtils.scryRenderedDOMComponentsWithClass progressBar, 'progress-label' expect(labelDiv.length).to.equal(0) #--------------------------------------------------------------------- CSS Classes it 'Should Render the appropriate CSS class when indeterminate', -> tickWidth = 25 progressBar = TestUtils.renderIntoDocument ProgressBar { indeterminate: true } progressBar.setState progWidth: 400 progressDiv = TestUtils.scryRenderedDOMComponentsWithClass progressBar, 'progress ind' indBarDivs = TestUtils.scryRenderedDOMComponentsWithClass progressBar, 'ind-bar' numOfIndBars = Math.floor(progressBar.state.progWidth/tickWidth) + 1 expect(progressDiv.length).to.equal(1) expect(indBarDivs.length).to.equal(numOfIndBars) it 'Should Render the appropriate CSS class when className property is passed', -> className = 'new-class' progressBar = TestUtils.renderIntoDocument ProgressBar { className: className } progressDiv = TestUtils.scryRenderedDOMComponentsWithClass progressBar, className expect(progressDiv.length).to.equal(1)