Skip to content

Commit

Permalink
add test for calendar dropdown
Browse files Browse the repository at this point in the history
  • Loading branch information
andela-akolawole committed Feb 8, 2017
1 parent 1bb9daf commit de4a0d2
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 1 deletion.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
"node-sass": "^3.10.1",
"react": "^15.3.2",
"react-addons-test-utils": "^15.3.2",
"react-day-picker": "^3.1.1",
"react-dom": "^15.3.2",
"stylelint": "^7.4.2",
"stylelint-scss": "^1.3.4",
Expand All @@ -76,6 +77,7 @@
"piping": "^1.0.0-rc.4",
"postcss-loader": "^1.1.1",
"sass-loader": "^4.0.2",
"sinon": "^1.17.7",
"style-loader": "^0.13.1",
"svg-loader": "0.0.2"
},
Expand Down
2 changes: 1 addition & 1 deletion src/components/calendar/calendarDropdown.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from 'react';
import DayPicker from 'react-day-picker';
import 'react-day-picker/lib/style.css';

export const CalendarDropdown = () => (
const CalendarDropdown = () => (
<div className="ui dropdown menu">
<div className="content">
<DayPicker
Expand Down
27 changes: 27 additions & 0 deletions src/components/calendar/calendarDropdown.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import React from 'react';
import { expect } from 'chai';
import { shallow } from 'enzyme';
import DayPicker from 'react-day-picker';
import CalendarDropdown from './calendarDropdown';

describe('<CalendarDropdown />', () => {
let wrapper;
beforeEach(() => {
wrapper = shallow(<CalendarDropdown />);
});
it('should render only one dropdown', () => {
expect(wrapper.find('.ui .dropdown .menu')).to.have.length(1);
});

it('should render the `show today` button', () => {
expect(wrapper.find('.ui .basic .button').text()).to.equal('Show Today');
});

it('should render the main contenet', () => {
expect(wrapper.find('.content')).to.have.length(1);
});

it('should render the day picker component with an initialMonth', () => {
expect(wrapper.contains(<DayPicker initialMonth={new Date(2017, 0)} />)).to.equal(true);
});
});

0 comments on commit de4a0d2

Please sign in to comment.