jest-extended icon indicating copy to clipboard operation
jest-extended copied to clipboard

New Matcher: toBeIso8601(Date), toBeIso8601Strict(Date)

Open benjaminkay93 opened this issue 6 years ago • 2 comments

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.

benjaminkay93 avatar Jul 03 '18 10:07 benjaminkay93

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 👍

mattphillips avatar Jul 30 '18 14:07 mattphillips

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

benjaminkay93 avatar Sep 07 '18 13:09 benjaminkay93