UNPKG

ldx-widgets

Version:

widgets

85 lines (51 loc) 2.54 kB
describe 'Note', -> React = require 'react' Note = React.createFactory require('../../src/components/note') TestUtils = require 'react-addons-test-utils' ReactDOM = require 'react-dom' #--------------------------------------------------------------------- Default Props it 'Should have default props', -> note = TestUtils.renderIntoDocument Note {} defaultProps = note.props expect(defaultProps.className).to.be.a('string') expect(defaultProps.headerText).to.be.a('string') #--------------------------------------------------------------------- Display Header Text it 'Should Render the headerText when headerText property is passed', -> headerText = 'Header Text' note = TestUtils.renderIntoDocument Note { headerText: headerText } headerTextDiv = TestUtils.findRenderedDOMComponentWithClass note, 'notes-header' expect(headerTextDiv.innerText).to.equal(headerText) #--------------------------------------------------------------------- Display note it 'Should Render the notes as a list when values property is an object', -> values = ['test1', 'test2'] note = TestUtils.renderIntoDocument Note { values: values } ulEl = TestUtils.scryRenderedDOMComponentsWithClass note, 'notes-list' textEl = TestUtils.scryRenderedDOMComponentsWithClass note, 'notes-text' expect(ulEl.length).to.equal(1) expect(textEl.length).to.equal(0) it 'Should Render the notes as test when values property is an string', -> values = 'test' note = TestUtils.renderIntoDocument Note { values: values } textEl = TestUtils.scryRenderedDOMComponentsWithClass note, 'notes-text' ulEl = TestUtils.scryRenderedDOMComponentsWithClass note, 'notes-list' expect(textEl.length).to.equal(1) expect(ulEl.length).to.equal(0) it 'Should Render the children when the children property is passed', -> noteText = 'Test' note = TestUtils.renderIntoDocument Note { children: noteText } divEl = TestUtils.findRenderedDOMComponentWithClass note, 'note' ulEl = TestUtils.scryRenderedDOMComponentsWithClass note, 'notes-list' textEl = TestUtils.scryRenderedDOMComponentsWithClass note, 'notes-text' headerTextDiv = TestUtils.scryRenderedDOMComponentsWithClass note, 'notes-header' expect(divEl.innerText).to.equal(noteText) expect(ulEl.length).to.equal(0) expect(textEl.length).to.equal(0) expect(headerTextDiv.length).to.equal(0)