Closed ewolfe closed 5 years ago
@dance2die any thoughts on this?
Wow. I am sorry I've not checked this PR (buried in deluge of emails).
May I ask what the issue was with the test?
Sure. Jest snapshots aren't asynchronous (at least without getting clever), so when my tests were running the "return" value from await calendarDates.getDates(...)
is undefined. Which isn't what I really wanted... I wanted the dates data.
This meant my React render method couldn't render my calendar, which meant my snapshot file was empty and wouldn't provide any confidence.
You can test async code by marking the callback with async. Not sure why your snapshot testing would not return data.
I'd like to keep the API async and anyway we can make your snapshot testing work?
I can probably get my snapshot testing working. I'm running snapshots via storyshots and they have a guide here. I'm probably just going to use my "sync" fork though since it makes things a little more straight forward.
Maybe I'm missing something though. Does keeping calendar-dates async have any benefits over a synchronous approach?
Synchronous will block the UI while async methods won't.
So if one has to show many months, sync methods will make the site look unresponsive.
I ran into the "issue" of this library being async while running jest snapshot testing.
This pull request refactors the API to be synchronous. It also updates all of the documentation, changelog, etc.