diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/HomeTest.hs | 24 | ||||
-rw-r--r-- | tests/main.hs | 22 |
2 files changed, 46 insertions, 0 deletions
diff --git a/tests/HomeTest.hs b/tests/HomeTest.hs new file mode 100644 index 0000000..17c9e6d --- /dev/null +++ b/tests/HomeTest.hs @@ -0,0 +1,24 @@ +module HomeTest + ( homeSpecs + ) where + +import Import +import Yesod.Test + +homeSpecs :: Specs +homeSpecs = + describe "These are some example tests" $ + it "loads the index and checks it looks right" $ do + get_ "/" + statusIs 200 + htmlAllContain "h1" "Hello" + + post "/" $ do + addNonce + fileByLabel "Choose a file" "tests/main.hs" "text/plain" -- talk about self-reference + byLabel "What's on the file?" "Some Content" + + statusIs 200 + htmlCount ".message" 1 + htmlAllContain ".message" "Some Content" + htmlAllContain ".message" "text/plain" diff --git a/tests/main.hs b/tests/main.hs new file mode 100644 index 0000000..d475fe8 --- /dev/null +++ b/tests/main.hs @@ -0,0 +1,22 @@ +{-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE NoMonomorphismRestriction #-} +{-# OPTIONS_GHC -fno-warn-orphans #-} + +module Main where + +import Import +import Settings +import Yesod.Logger (defaultDevelopmentLogger) +import Yesod.Default.Config +import Yesod.Test +import Application (makeFoundation) + +import HomeTest + +main :: IO a +main = do + conf <- loadConfig $ (configSettings Testing) { csParseExtra = parseExtra } + logger <- defaultDevelopmentLogger + foundation <- makeFoundation conf logger + app <- toWaiAppPlain foundation + runTests app (connPool foundation) homeSpecs |