2017-05-25 19:12:29 +00:00
|
|
|
module HTTPure.ResponseSpec where
|
|
|
|
|
2017-07-18 05:31:46 +00:00
|
|
|
import Prelude
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
import Control.Monad.Eff.Class as EffClass
|
2017-07-14 06:28:57 +00:00
|
|
|
import Data.StrMap as StrMap
|
2017-07-10 10:17:13 +00:00
|
|
|
import Test.Spec as Spec
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
import HTTPure.Response as Response
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-14 06:28:57 +00:00
|
|
|
import HTTPure.SpecHelpers as SpecHelpers
|
2017-07-19 05:36:56 +00:00
|
|
|
import HTTPure.SpecHelpers ((?=))
|
2017-07-14 06:28:57 +00:00
|
|
|
|
|
|
|
sendSpec :: SpecHelpers.Test
|
|
|
|
sendSpec = Spec.describe "send" do
|
2017-07-19 18:59:55 +00:00
|
|
|
Spec.it "writes the headers" do
|
|
|
|
header <- EffClass.liftEff do
|
|
|
|
resp <- SpecHelpers.mockResponse
|
|
|
|
Response.send resp $ Response.OK (StrMap.singleton "X-Test" "test") ""
|
|
|
|
pure $ SpecHelpers.getResponseHeader "X-Test" resp
|
|
|
|
header ?= "test"
|
|
|
|
Spec.it "writes the status" do
|
|
|
|
status <- EffClass.liftEff do
|
|
|
|
resp <- SpecHelpers.mockResponse
|
|
|
|
Response.send resp $ Response.Response 465 StrMap.empty ""
|
|
|
|
pure $ SpecHelpers.getResponseStatus resp
|
|
|
|
status ?= 465
|
|
|
|
Spec.it "writes the body" do
|
|
|
|
body <- EffClass.liftEff do
|
|
|
|
resp <- SpecHelpers.mockResponse
|
|
|
|
Response.send resp $ Response.OK StrMap.empty "test"
|
|
|
|
pure $ SpecHelpers.getResponseBody resp
|
|
|
|
body ?= "test"
|
2017-07-10 10:17:13 +00:00
|
|
|
|
|
|
|
responseSpec :: SpecHelpers.Test
|
2017-07-14 06:28:57 +00:00
|
|
|
responseSpec = Spec.describe "Response" do
|
|
|
|
sendSpec
|