elm-test
elm-test copied to clipboard
Fuzzer.date
After looking through the docs I was surprised to not find a fuzzer for dates.
After asking on Slack @zwilias said:
You could potentially do something like fuzzing a float in a certain range and doing
map Date.fromTimeon that you'd have to figure out what sort of granularity and range you want, though
I think it would be nice to have a date fuzzer in this package, so opening an issue for further discussions
Here are some possible implementations (untested):
import Fuzz exposing (..)
import Date exposing (Date)
import Time exposing (Time)
time : Fuzzer Time
time =
map ((*) Time.second) <| Fuzz.floatRange 0 2524608000
date : Fuzzer Date
date =
map Date.fromTime time