]> Git — Sourcephile - comptalang.git/blob - web/test/Handler/HomeSpec.hs
Ajout : Calc.Balance : Amount_Sum.
[comptalang.git] / web / test / Handler / HomeSpec.hs
1 module Handler.HomeSpec (spec) where
2
3 import TestImport
4
5 spec :: Spec
6 spec = withApp $ do
7 it "loads the index and checks it looks right" $ do
8 get HomeR
9 statusIs 200
10 htmlAllContain "h1" "Welcome to Yesod"
11
12 request $ do
13 setMethod "POST"
14 setUrl HomeR
15 addToken
16 fileByLabel "Choose a file" "test/Spec.hs" "text/plain" -- talk about self-reference
17 byLabel "What's on the file?" "Some Content"
18
19 statusIs 200
20 -- more debugging printBody
21 htmlCount ".message" 1
22 htmlAllContain ".message" "Some Content"
23 htmlAllContain ".message" "text/plain"
24
25 -- This is a simple example of using a database access in a test. The
26 -- test will succeed for a fresh scaffolded site with an empty database,
27 -- but will fail on an existing database with a non-empty user table.
28 it "leaves the user table empty" $ do
29 get HomeR
30 statusIs 200
31 users <- runDB $ selectList ([] :: [Filter User]) []
32 assertEqual "user table empty" 0 $ length users