This repository has been archived on 2024-04-08. You can view files and clone it, but cannot push or open issues/pull-requests.
nates-mazes/tests/RouteTests.elm

51 lines
1.3 KiB
Elm

module RouteTests exposing (..)
import Expect
import Fuzz exposing (Fuzzer)
import Route exposing (Route)
import Test exposing (..)
import Url
roundTrip : Test
roundTrip =
fuzz routeFuzzer "toAbsolutePath -> parse is a round trip" <|
\route ->
case Url.fromString ("https://example.com" ++ Route.toAbsolutePath route) of
Just url ->
url
|> Route.parse
|> Expect.equal route
Nothing ->
Expect.fail "could not generate a URL from the given route"
routeFuzzer : Fuzzer Route
routeFuzzer =
Fuzz.oneOf
[ Fuzz.constant Route.New
, Fuzz.map4
(\shape seed width height ->
Route.Maze
{ shape = shape
, seed = seed
, width = width
, height = height
}
)
mazeShapeFuzzer
(Fuzz.intRange 0 1)
(Fuzz.intRange 0 1)
(Fuzz.intRange 0 1)
, Fuzz.constant Route.NotFound
]
mazeShapeFuzzer : Fuzzer Route.MazeShape
mazeShapeFuzzer =
Fuzz.oneOf
[ Fuzz.constant Route.Squares
, Fuzz.constant Route.Hexes
]