{-# LANGUAGE OverloadedStrings #-}import Data.List.NonEmpty.Compat ( NonEmpty(..) )import Test.Tastyimport Test.Tasty.Waiimport Network.HTTP.Types ( status200 )import Network.Wai ( Application , responseLBS )import Network.Wai.Middleware.Clacksmain :: IO ()main = defaultMain teststests :: TestTreetests = testGroup "Wai Tests" [testSingle, testMultiple, testExisting] where testSingle :: TestTree testSingle = testWai (simpleApp gnuTerryPratchett) "Single Message" $ do get "42" >>= assertHeader clacksHeaderName "GNU Terry Pratchett" testMultiple :: TestTree testMultiple = let settings = Clacks $ "GNU Terry Pratchett" :| ["GNU Ada Lovelace"] in testWai (simpleApp settings) "Multiple Messages" $ get "9001" >>= assertHeader clacksHeaderName "GNU Terry Pratchett,GNU Ada Lovelace" testExisting :: TestTree testExisting = testWai (existingHeaderApp gnuTerryPratchett) "Existing Clacks Header" $ do get "neko" >>= assertHeader clacksHeaderName "GNU Ada Lovelace,GNU Terry Pratchett"simpleApp :: Clacks -> ApplicationsimpleApp settings = clacks settings $ \_ cb -> cb $ responseLBS status200 [] "Hello World"existingHeaderApp :: Clacks -> ApplicationexistingHeaderApp settings = clacks settings $ \_ cb -> cb $ responseLBS status200 [(clacksHeaderName, "GNU Ada Lovelace")] "Hello World"