jest-extended
jest-extended copied to clipboard
New Matcher: toBeIso8601(Date), toBeIso8601Strict(Date)
Feature Request
Description: 2 matcher's, to test for a date string matching the ISO8601 standard.
- toBeIso8601() to test the string complies to the pretty loose ISO8601 standard.
- toBeIso8601Strict() to test that the string matches for an exact ISO8601 time in UTC YYYY-MM-DDTHH:MM:SS.SSSZ
Possible solution: Regex matchers for the Strict varient would be rather simple, however the standard itself is rather complex and could end up with multiple regex's if done literally. However if this is something people would want I can raise a PR myself for this :), I feel I should of done this before raising the PR for toHaveBeenCalledAfter(), appologise if this is the prefared way for this community to raise issues before PR's.
Hey @benjaminkay93 I like the proposed matchers :smile: I agree the simple variant could be a bit painful with all of the edge cases but if you are up for the challenge feel free to send a PR 👍
Raised the toBeIso8601Strict here https://github.com/jest-community/jest-extended/pull/164 , but not touched the toBeIso8601 yet, feeling its gonna be abit of a faff :P