Skip to content

Fix: DateAssertion.toBeDayOfWeek when using "sunday" - #76

Merged
JoseLion merged 3 commits into
stackbuilders:mainfrom
neolight1010:fix/sunday-to-be-day-of-week
Oct 24, 2022
Merged

JoseLion merged 3 commits into
stackbuilders:mainfrom
neolight1010:fix/sunday-to-be-day-of-week

Conversation

@neolight1010

Copy link
Copy Markdown
Contributor

This PR fixes #75 . I chose this implementation so the .toBeDayOfWeek matcher's behavior is consistent with Javascript's Date.getDay and with .toBeDayOfWeek's documentation. I also changed its docs so it's clear what a number literal means when using the matcher.

I also think there should be a .toBeISODayOfWeek matcher, to avoid further confusion.

Changes

  • Add a test that exposes the issue.
  • Change convertion of "sunday" to 0 instead of 7.
  • Improve .toBeDayOfWeek docs.

This makes the implementation consistent with JS' Date.getDay() and with
DateAssertion.toBeDayOfWeek()'s documentation.
This makes the meaning of number literals clear when using
.toBeDayOfWeek().
@neolight1010
neolight1010 requested a review from JoseLion as a code owner October 7, 2022 14:04

@JoseLion JoseLion left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch! Thanks a lot for your contribution @neolight1010 🎉

@JoseLion JoseLion added the hacktoberfest-accepted PRs accepted during Hacktoberfest label Oct 24, 2022
@JoseLion
JoseLion merged commit 1ced1e4 into stackbuilders:main Oct 24, 2022
@neolight1010
neolight1010 deleted the fix/sunday-to-be-day-of-week branch October 24, 2022 15:33
@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 1.0.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

hacktoberfest-accepted PRs accepted during Hacktoberfest released

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DateAssertion.toBeDayOfWeek fails on Sunday dates when comparing to "sunday" literal

2 participants