Skip to content
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

DateDiffGreaterThanAssert is throwing violations when it shouldn't #163

Open
rplopes opened this issue Oct 19, 2016 · 1 comment
Open

DateDiffGreaterThanAssert is throwing violations when it shouldn't #163

rplopes opened this issue Oct 19, 2016 · 1 comment
Labels
bug Something isn't working

Comments

@rplopes
Copy link
Contributor

rplopes commented Oct 19, 2016

Example where we assert that a date 13 years and 2 days ago is older than 13 years ago:

is.dateDiffGreaterThan(13, { unit: 'years' }).check(moment().subtract(13, 'years').subtract(2, 'days').toDate())

Expected result:

true

Actual result:

// Violation (DateDiffGreaterThan)

This seems to be because this diff is being calculated at the unit's granularity (years, in this example), so 13 years and 2 days ago is rounded to 13 years ago, which is equal, not greater than the assert date.

@rplopes rplopes added the bug Something isn't working label Oct 19, 2016
@pedrobranco
Copy link
Member

Don't know if this assert (and other date asserts) supposedly should be able to compare two dates.

Testing if 2015-12-31 if is greater than or equal to date 2016-01-01:

is.dateDiffGreaterThanOrEqualTo(0, { fromDate: new Date('2016-01-01') }).check(new Date('2015-12-31'))

Expected result:

// Violation (DateDiffGreaterThanOrEqualTo)

Actual result:

true

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants