elm-pages-v3-beta/tests/FormParserTests.elm
2022-06-02 11:30:15 -07:00

45 lines
1.3 KiB
Elm

module FormParserTests exposing (all)
import Dict exposing (Dict)
import Expect
import Pages.Form
import Pages.FormParser as FormParser
import Test exposing (Test, describe, test)
formDecoder : FormParser.Parser String ( String, String )
formDecoder =
FormParser.map2 Tuple.pair
(FormParser.required "first" "First is required")
(FormParser.required "last" "Last is required")
all : Test
all =
describe "Path"
[ test "join two segments" <|
\() ->
FormParser.run
(Dict.fromList
[ ( "first"
, { value = ""
, status = Pages.Form.NotVisited
}
)
, ( "last"
, { value = ""
, status = Pages.Form.NotVisited
}
)
]
)
formDecoder
|> Expect.equal
( Just ( "", "" )
, Dict.fromList
[ ( "first", [ "First is required" ] )
, ( "last", [ "Last is required" ] )
]
)
]