yesod-test 1.2.1.5 → 1.2.2
raw patch · 3 files changed
+27/−1 lines, 3 filesPVP ok
version bump matches the API change (PVP)
API changes (from Hackage documentation)
+ Yesod.Test: htmlNoneContain :: Query -> String -> YesodExample site ()
Files
- Yesod/Test.hs +14/−0
- test/main.hs +12/−0
- yesod-test.cabal +1/−1
Yesod/Test.hs view
@@ -75,6 +75,7 @@ , bodyContains , htmlAllContain , htmlAnyContain+ , htmlNoneContain , htmlCount -- * Grab information@@ -352,6 +353,19 @@ [] -> failure $ "Nothing matched css query: " <> query _ -> liftIO $ HUnit.assertBool ("None of "++T.unpack query++" contain "++search) $ DL.any (DL.isInfixOf search) (map (TL.unpack . decodeUtf8) matches)++-- | Queries the html using a css selector, and fails if any matched+-- element contains the given string (in other words, it is the logical+-- inverse of htmlAnyContains).+--+-- Since 1.2.2+htmlNoneContain :: Query -> String -> YesodExample site ()+htmlNoneContain query search = do+ matches <- htmlQuery query+ case DL.filter (DL.isInfixOf search) (map (TL.unpack . decodeUtf8) matches) of+ [] -> return ()+ found -> failure $ "Found " <> T.pack (show $ length found) <>+ " instances of " <> T.pack search <> " in " <> query <> " elements" -- | Performs a css query on the last response and asserts the matched elements -- are as many as expected.
test/main.hs view
@@ -109,6 +109,15 @@ addNonce statusIs 200 bodyEquals "12345"+ yit "finding html" $ do+ get ("/html" :: Text)+ statusIs 200+ htmlCount "p" 2+ htmlAllContain "p" "Hello"+ htmlAnyContain "p" "World"+ htmlAnyContain "p" "Moon"+ htmlNoneContain "p" "Sun"+ ydescribe "utf8 paths" $ do yit "from path" $ do get ("/dynamic1/שלום" :: Text)@@ -162,6 +171,9 @@ case mfoo of FormSuccess (foo, _) -> return $ toHtml foo _ -> defaultLayout widget+ onStatic "html" $ dispatchTo $+ return ("<html><head><title>Hello</title></head><body><p>Hello World</p><p>Hello Moon</p></body></html>" :: Text)+ cookieApp :: LiteApp cookieApp = liteApp $ do
yesod-test.cabal view
@@ -1,5 +1,5 @@ name: yesod-test-version: 1.2.1.5+version: 1.2.2 license: MIT license-file: LICENSE author: Nubis <nubis@woobiz.com.ar>