-
-
Notifications
You must be signed in to change notification settings - Fork 760
Feature: onCaptionClick #31
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Allows developer to specificy an onCaptionClick prop to be run when user clicks on the caption (month display in header)
|
Awesome thank you! Do you want to add a test for it, or should I? :-) Coveralls is in maintenance mode and doesn't report the coverage status on github. |
|
No problem!
So this is an area I'm admittedly not well practiced in so I would definitely appreciate the help if you wouldn't mind. I'd also love to take a look at the tests once they've been proposed just to learn from and hopefully get a bit better at. |
|
It's very easy to add the test. Take this one as example to start. Your test should be very similar:
The last part is a bit more complex as you need to know the syntax of // get the SyntheticEvent class from react's lib
const SyntheticEvent = require("react/lib/SyntheticEvent");
expect(handleCaptionClick).to.have.been.calledWith(
// Make sure the first argument receved is an instance of SyntheticEvent
sinon.match((e) => {
return e instanceof SyntheticEvent && e.target !== null;
}, "e"),
// Make sure the second argument is the calendar's current month,
// e.g. the initial month
sinon.match((currentMonth) => {
let today = new Date();
return currentMonth.getFullYear() === today.getFullYear() &&
currentMonth.getMonth() === today.getMonth();
}, "currentMonth"),
);run If you run |
Also updated parameters of (e, month) to -> (e, currentMonth) to be more explicit
|
Awesome, thank for the write up! Very informative and helpful. I've gone ahead and added that test via 74ca15c. |
|
thanks man! published as |
|
🎉 |
Adds an optional
onCaptionClickprop (similar toonDayClick) that allows developer to specify a function to be run when the user clicks the caption in the header (month display).