aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/Cana/ProtocolSpec.hs27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/Cana/ProtocolSpec.hs b/test/Cana/ProtocolSpec.hs
new file mode 100644
index 0000000..6effd25
--- /dev/null
+++ b/test/Cana/ProtocolSpec.hs
@@ -0,0 +1,27 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Cana.ProtocolSpec where
+
+import Cana.Protocol
+import Test.Hspec
+
+spec :: Spec
+spec = do
+ describe "renderResponse" $ do
+ it "correctly renders a success response" $ do
+ let response = GeminiResponse
+ { responseStatus = codeSuccess
+ , responseMeta = "text/gemini"
+ , responseData = "# Hello World!"
+ }
+ wanted = "20 text/gemini\r\n# Hello World!"
+ renderResponse response `shouldBe` wanted
+
+ describe "parseResponse" $ do
+ it "correctly parses a success response" $ do
+ let response = GeminiResponse
+ { responseStatus = codeSuccess
+ , responseMeta = "text/gemini"
+ , responseData = "# Hello World!"
+ }
+ wanted = "20 text/gemini\r\n# Hello World!"
+ parseResponse wanted `shouldBe` Just response