mirror of
https://github.com/encounter/react-add-to-calendar.git
synced 2026-07-10 21:18:44 -07:00
Adds the option to show calendar links when mounted (#15)
This commit is contained in:
committed by
Jason Salzman
parent
a354170f89
commit
66d602884b
@@ -77,3 +77,6 @@ defaultValue: `[
|
||||
type: `string`
|
||||
defaultValue: `'react-add-to-calendar'`
|
||||
|
||||
### `optionsOpen`
|
||||
type: `bool`
|
||||
defaultValue: `false`
|
||||
|
||||
@@ -9,7 +9,7 @@ export default class ReactAddToCalendar extends React.Component {
|
||||
super(props);
|
||||
|
||||
this.state = {
|
||||
optionsOpen: false,
|
||||
optionsOpen: props.optionsOpen || false,
|
||||
isCrappyIE: false
|
||||
};
|
||||
|
||||
@@ -196,6 +196,7 @@ ReactAddToCalendar.propTypes = {
|
||||
buttonTemplate: PropTypes.object,
|
||||
buttonWrapperClass: PropTypes.string,
|
||||
displayItemIcons: PropTypes.bool,
|
||||
optionsOpen: PropTypes.bool,
|
||||
dropdownClass: PropTypes.string,
|
||||
event: PropTypes.shape({
|
||||
title: PropTypes.string,
|
||||
@@ -215,6 +216,7 @@ ReactAddToCalendar.defaultProps = {
|
||||
buttonTemplate: { caret: "right" },
|
||||
buttonWrapperClass: "react-add-to-calendar__wrapper",
|
||||
displayItemIcons: true,
|
||||
optionsOpen: false,
|
||||
dropdownClass: "react-add-to-calendar__dropdown",
|
||||
event: {
|
||||
title: "Sample Event",
|
||||
|
||||
@@ -25,6 +25,24 @@ describe("AddToCalendar", () => {
|
||||
expect(dropdown).to.exist;
|
||||
});
|
||||
|
||||
it("should show the options menu if optionsOpen is true", () => {
|
||||
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} optionsOpen />
|
||||
);
|
||||
var dropdown = TestUtils.findRenderedDOMComponentWithClass(
|
||||
addToCalendar,
|
||||
"react-add-to-calendar__dropdown"
|
||||
);
|
||||
expect(dropdown).to.exist;
|
||||
});
|
||||
|
||||
it("should mount and unmount properly", done => {
|
||||
var TestComponent = createReactClass({
|
||||
displayName: "TestComponent",
|
||||
|
||||
Reference in New Issue
Block a user