elm-pages-v3-beta/tests/FormParserTests.elm

45 lines
1.3 KiB
Elm
Raw Normal View History

2022-06-02 21:30:15 +03:00
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" ] )
]
)
]