@@ -322,6 +322,15 @@ main = hspec $ do
322322 chooseByLabel " Blue"
323323 addToken
324324 bodyContains " colorRadioButton = Just Blue"
325+ yit " can click check boxes" $ do
326+ get (" /labels-checkboxes" :: Text )
327+ request $ do
328+ setMethod " POST"
329+ setUrl (" /labels-checkboxes" :: Text )
330+ checkByLabel " Red"
331+ checkByLabel " Gray"
332+ addToken
333+ bodyContains " colorCheckBoxes = [Gray,Red]"
325334
326335 ydescribe " byLabel-related tests" $ do
327336 yit " fails with \" More than one label contained\" error" $ do
@@ -667,19 +676,34 @@ app = liteApp $ do
667676 onStatic " labels-radio-buttons" $ dispatchTo $ do
668677 ((result, widget), _) <- runFormPost
669678 $ renderDivs
670- $ ColorForm <$> aopt (radioField' optionsEnum) " Color" Nothing
679+ $ RadioButtonForm <$> aopt (radioField' optionsEnum) " Color" Nothing
671680 case result of
672681 FormSuccess color -> return $ toHtml $ show color
673682 _ -> defaultLayout [whamlet |$newline never
683+ <p>
684+ ^{toHtml $ show result}
674685 <form method=post action="labels-radio-buttons">
675686 ^{widget}
676687 |]
677688
689+ onStatic " labels-checkboxes" $ dispatchTo $ do
690+ ((result, widget), _) <- runFormPost
691+ $ renderDivs
692+ $ CheckboxesForm <$> areq (checkboxesField' optionsEnum) " Checkboxes" (Just [Blue , Black ])
693+ case result of
694+ FormSuccess color -> return $ toHtml $ show color
695+ _ -> defaultLayout [whamlet |$newline never
696+ <p>
697+ ^{toHtml $ show result}
698+ <form method=post action="labels-checkboxes">
699+ ^{widget}
700+ |]
701+
678702data Color = Red | Blue | Gray | Black
679703 deriving (Show , Eq , Enum , Bounded )
680704
681- newtype ColorForm = ColorForm { colorRadioButton :: Maybe Color }
682- deriving Show
705+ newtype RadioButtonForm = RadioButtonForm { colorRadioButton :: Maybe Color } deriving Show
706+ newtype CheckboxesForm = CheckboxesForm { colorCheckBoxes :: [ Color ] } deriving Show
683707
684708cookieApp :: LiteApp
685709cookieApp = liteApp $ do
0 commit comments