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
Fix corner cases #460
Fix corner cases #460
Conversation
new Date(NaN) | ||
) | ||
assert(result === false) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's worth to add a tests case with isSameDay(new Date(NaN), new Date(NaN))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work 👍
new Date(NaN) | ||
) | ||
assert(result === false) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add test case for isAfter(new Date(NaN), new Date(NaN))
it('throws an exception if the end date of the compared time interval is `Invalid Date`', function () { | ||
var block = areIntervalsOverlapping.bind( | ||
null, | ||
{start: new Date(2016, 10, 3), end: new Date(2016, 10, 7)}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's use RangeError
for the exception.
new Date(2012, 6 /* Jul */, 2) | ||
]) | ||
assert(isNaN(result)) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add test case when the given array contains an unexpected value such as undefined
.
CHANGELOG.md
Outdated
@@ -328,6 +328,10 @@ This change log follows the format documented in [Keep a CHANGELOG]. | |||
) | |||
``` | |||
|
|||
- **BREAKING**: functions now throw `RangeError` if optional values passed to `options` | |||
are not `undefined` or have expected values. | |||
This change is introduced for consistency with ECMAScript's `Intl` which does the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add a comment about arithmetic operations with NaN
* Invalid Date tests for `addX`, `setX` and `subX` * Invalid Date tests for `getX` * Invalid Date tests for `startOfX`, `endOfX` and `lastDayOfX` * Invalid Date tests for `isSameX` * Invalid Date tests for `differenceInX` * `isX(new Date(NaN))` tests * `isAfter`, `isBefore` and `isEqual` Invalid Date tests * Interval functions Invalid Date tests * `compareAsc` and `compareDesc` Invalid Date tests * `closestTo`, `closestIndexTo`, `max` and `min` Invalid Date tests * Test `toDate` if `options.additionalDigits` is not 0, 1, 2 or undefined * Test `parse` if baseDate is `Invalid Date` * `distanceInWords` and `distanceInWordsStrict` invalid values tests * Invalid `options.weekStartsOn` tests * Invalid value implementation fixes * `parse` implementation fix * `weekStartsOn` implementation fix * Rename `partialMethod` to `roundingMethod` * `distanceInWordsStrict` implementation fix * Rebuild typings * `toDate` implementation fix * Add CHANGELOG.md entry * Add missing tests * Make interval functions throw RangeError * Fix @throws docs messages * Add `@throws {RangeError}` to all functions docs * Add `@param [options.additionalDigits]` to all functions docs * Add `options.additionalDigits` tests to all functions * Complete corner cases changelog entry * Add missing `$ExpectedMistake`
* Invalid Date tests for `addX`, `setX` and `subX` * Invalid Date tests for `getX` * Invalid Date tests for `startOfX`, `endOfX` and `lastDayOfX` * Invalid Date tests for `isSameX` * Invalid Date tests for `differenceInX` * `isX(new Date(NaN))` tests * `isAfter`, `isBefore` and `isEqual` Invalid Date tests * Interval functions Invalid Date tests * `compareAsc` and `compareDesc` Invalid Date tests * `closestTo`, `closestIndexTo`, `max` and `min` Invalid Date tests * Test `toDate` if `options.additionalDigits` is not 0, 1, 2 or undefined * Test `parse` if baseDate is `Invalid Date` * `distanceInWords` and `distanceInWordsStrict` invalid values tests * Invalid `options.weekStartsOn` tests * Invalid value implementation fixes * `parse` implementation fix * `weekStartsOn` implementation fix * Rename `partialMethod` to `roundingMethod` * `distanceInWordsStrict` implementation fix * Rebuild typings * `toDate` implementation fix * Add CHANGELOG.md entry * Add missing tests * Make interval functions throw RangeError * Fix @throws docs messages * Add `@throws {RangeError}` to all functions docs * Add `@param [options.additionalDigits]` to all functions docs * Add `options.additionalDigits` tests to all functions * Complete corner cases changelog entry * Add missing `$ExpectedMistake`
* Invalid Date tests for `addX`, `setX` and `subX` * Invalid Date tests for `getX` * Invalid Date tests for `startOfX`, `endOfX` and `lastDayOfX` * Invalid Date tests for `isSameX` * Invalid Date tests for `differenceInX` * `isX(new Date(NaN))` tests * `isAfter`, `isBefore` and `isEqual` Invalid Date tests * Interval functions Invalid Date tests * `compareAsc` and `compareDesc` Invalid Date tests * `closestTo`, `closestIndexTo`, `max` and `min` Invalid Date tests * Test `toDate` if `options.additionalDigits` is not 0, 1, 2 or undefined * Test `parse` if baseDate is `Invalid Date` * `distanceInWords` and `distanceInWordsStrict` invalid values tests * Invalid `options.weekStartsOn` tests * Invalid value implementation fixes * `parse` implementation fix * `weekStartsOn` implementation fix * Rename `partialMethod` to `roundingMethod` * `distanceInWordsStrict` implementation fix * Rebuild typings * `toDate` implementation fix * Add CHANGELOG.md entry * Add missing tests * Make interval functions throw RangeError * Fix @throws docs messages * Add `@throws {RangeError}` to all functions docs * Add `@param [options.additionalDigits]` to all functions docs * Add `options.additionalDigits` tests to all functions * Complete corner cases changelog entry * Add missing `$ExpectedMistake`
* Invalid Date tests for `addX`, `setX` and `subX` * Invalid Date tests for `getX` * Invalid Date tests for `startOfX`, `endOfX` and `lastDayOfX` * Invalid Date tests for `isSameX` * Invalid Date tests for `differenceInX` * `isX(new Date(NaN))` tests * `isAfter`, `isBefore` and `isEqual` Invalid Date tests * Interval functions Invalid Date tests * `compareAsc` and `compareDesc` Invalid Date tests * `closestTo`, `closestIndexTo`, `max` and `min` Invalid Date tests * Test `toDate` if `options.additionalDigits` is not 0, 1, 2 or undefined * Test `parse` if baseDate is `Invalid Date` * `distanceInWords` and `distanceInWordsStrict` invalid values tests * Invalid `options.weekStartsOn` tests * Invalid value implementation fixes * `parse` implementation fix * `weekStartsOn` implementation fix * Rename `partialMethod` to `roundingMethod` * `distanceInWordsStrict` implementation fix * Rebuild typings * `toDate` implementation fix * Add CHANGELOG.md entry * Add missing tests * Make interval functions throw RangeError * Fix @throws docs messages * Add `@throws {RangeError}` to all functions docs * Add `@param [options.additionalDigits]` to all functions docs * Add `options.additionalDigits` tests to all functions * Complete corner cases changelog entry * Add missing `$ExpectedMistake`
* Invalid Date tests for `addX`, `setX` and `subX` * Invalid Date tests for `getX` * Invalid Date tests for `startOfX`, `endOfX` and `lastDayOfX` * Invalid Date tests for `isSameX` * Invalid Date tests for `differenceInX` * `isX(new Date(NaN))` tests * `isAfter`, `isBefore` and `isEqual` Invalid Date tests * Interval functions Invalid Date tests * `compareAsc` and `compareDesc` Invalid Date tests * `closestTo`, `closestIndexTo`, `max` and `min` Invalid Date tests * Test `toDate` if `options.additionalDigits` is not 0, 1, 2 or undefined * Test `parse` if baseDate is `Invalid Date` * `distanceInWords` and `distanceInWordsStrict` invalid values tests * Invalid `options.weekStartsOn` tests * Invalid value implementation fixes * `parse` implementation fix * `weekStartsOn` implementation fix * Rename `partialMethod` to `roundingMethod` * `distanceInWordsStrict` implementation fix * Rebuild typings * `toDate` implementation fix * Add CHANGELOG.md entry * Add missing tests * Make interval functions throw RangeError * Fix @throws docs messages * Add `@throws {RangeError}` to all functions docs * Add `@param [options.additionalDigits]` to all functions docs * Add `options.additionalDigits` tests to all functions * Complete corner cases changelog entry * Add missing `$ExpectedMistake`
No description provided.