Skip to content
LucidDemo.hs 787 B
Newer Older
import Data.Text.Lazy (Text)
import qualified Data.Text.Lazy as L
import Lucid
import Test.Hspec

{-# ANN module ("HLint: ignore Redundant do" :: String) #-}

value1 :: Text
value1 = "value1"

demoPage :: IO Text
demoPage = return $ renderText $ do
    head_ (title_ "recent calls")
    body_ $ table_ $ do
      tr_ $ do
        th_ "field1"
        th_ "field2"
        th_ "field3"
      tr_ $ do
        td_ (toHtml value1)
        td_ "value2"
        td_ "value3"

main :: IO ()
main = hspec $ do
  describe "demoPage" $ do
    it "should work" $ do
      text <- demoPage
      text `shouldBe` L.pack "<head><title>recent calls</title></head><body><table><tr><th>field1</th><th>field2</th><th>field3</th></tr><tr><td>value1</td><td>value2</td><td>value3</td></tr></table></body>"