Skip to content

Commit

Permalink
Add test for renderMonthElement
Browse files Browse the repository at this point in the history
  • Loading branch information
gidztech committed Apr 8, 2019
1 parent e1f5bd3 commit 1924094
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/components/CalendarMonth_spec.jsx
@@ -1,6 +1,7 @@
import React from 'react';
import { expect } from 'chai';
import { shallow } from 'enzyme';
import sinon from 'sinon-sandbox';
import moment from 'moment';

import CalendarMonth from '../../src/components/CalendarMonth';
Expand All @@ -26,5 +27,24 @@ describe('CalendarMonth', () => {
expect(captionWrapper.text()).to.equal(MONTH.format('MMMM YYYY'));
});
});

it('renderMonthElement renders month element when month changes', () => {
const renderMonthElementStub = sinon.stub().returns(<div id="month-element" />);
const wrapper = shallow(<CalendarMonth renderMonthElement={renderMonthElementStub} />).dive();
wrapper.setProps({ month: moment().subtract(1, 'months') });

const [{
month,
onMonthSelect,
onYearSelect,
isVisible,
}] = renderMonthElementStub.getCall(0).args;

expect(moment.isMoment(month)).to.equal(true);
expect(typeof onMonthSelect).to.equal('function');
expect(typeof onYearSelect).to.equal('function');
expect(typeof isVisible).to.equal('boolean');
expect(wrapper.find('#month-element').exists()).to.equal(true);
});
});
});

0 comments on commit 1924094

Please sign in to comment.