mirror of
https://github.com/dillonkearns/elm-pages-v3-beta.git
synced 2024-11-25 20:05:29 +03:00
45 lines
1.3 KiB
Elm
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" ] )
|
||
|
]
|
||
|
)
|
||
|
]
|