Files
react-add-to-calendar/test/add-to-calendar_test.js
T
2016-10-06 11:10:21 -07:00

39 lines
1.3 KiB
JavaScript

import React from 'react'
import ReactDOM from 'react-dom'
import TestUtils from 'react-addons-test-utils'
import AddToCalendar from '../src/ReactAddToCalendar.js'
describe('AddToCalendar', () => {
it('should show the options menu when the button is clicked', () => {
var event = {
title: 'Sample Event',
description: 'This is the sample event provided as an example only',
location: 'Portland, OR',
startTime: '2016-09-16T20:15:00-04:00',
endTime: '2016-09-16T21:45:00-04:00'
}
var addToCalendar = TestUtils.renderIntoDocument(
<AddToCalendar event={event} />
)
var button = TestUtils.findRenderedDOMComponentWithTag(addToCalendar, 'a')
TestUtils.Simulate.click(ReactDOM.findDOMNode(button))
var dropdown = TestUtils.findRenderedDOMComponentWithClass(addToCalendar, 'react-add-to-calendar__dropdown')
expect(dropdown).to.exist
})
it('should mount and unmount properly', done => {
var TestComponent = React.createClass({
displayName: 'TestComponent',
getInitialState () {
return { mounted: true }
},
render () {
return this.state.mounted ? <AddToCalendar /> : null
}
})
var element = TestUtils.renderIntoDocument(<TestComponent />)
element.setState({ mounted: false }, done)
})
})