elm-explorations / elm-explorations/test
Any way to test the result of a Fuzz.maybe or force a Just?
- Dominant language
- Elm
- Stars
- 244
- Forks
- 40
- Avg merge
- 1d 23h
- Merged PRs (30d)
- 2
Description
I think my case may be another +1 for #17, but perhaps there's another way to go about this.
How should one formulate fuzz tests with the dependence of one maybe type on another type?
My case:
```elm
type Position
= Delta Int Int (List Int)
| Coordinate Float Float (List Float)
type alias Transform =
{ ... }
fuzzTransform : Fuzzer (Maybe Transform)
fuzzPosition : Fuzzer Position
```
I'd like to pattern match the `fuzzTransform` in the `fuzzPosition` fuzzer, perhaps like this:
```elm
fuzzPosition : Maybe Transform -> Fuzzer Position
fuzzPosition transform =
case transform of
Just _ ->
fuzzDelta
Nothing ->
fuzzCoordinate
```
I don't see how to do this without `Fuzz.andThen`, nor if I were to use a custom fuzzer. Is there a way to perhaps use something like:
```elm
fuzzTransform : Fuzzer Transform
fuzzPosition : Fuzzer Position
fuzzPosition =
Fuzz.frequency
[ ( 1, positionHelper Nothing )
, ( 3, positionHelper (Just fuzzTransform) )
]
```
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.