2017-07-14 06:28:57 +00:00
|
|
|
module HTTPure.BodySpec where
|
|
|
|
|
2017-07-17 23:42:13 +00:00
|
|
|
import Prelude (bind, discard, pure, ($))
|
2017-07-14 06:28:57 +00:00
|
|
|
|
2017-07-17 23:42:13 +00:00
|
|
|
import Control.Monad.Eff.Class as EffClass
|
2017-07-18 05:25:14 +00:00
|
|
|
import Data.StrMap as StrMap
|
2017-07-14 06:28:57 +00:00
|
|
|
import Test.Spec as Spec
|
2017-07-17 23:42:13 +00:00
|
|
|
import Test.Spec.Assertions as Assertions
|
|
|
|
|
|
|
|
import HTTPure.Body as Body
|
2017-07-14 06:28:57 +00:00
|
|
|
|
|
|
|
import HTTPure.SpecHelpers as SpecHelpers
|
|
|
|
|
2017-07-18 05:25:14 +00:00
|
|
|
readSpec :: SpecHelpers.Test
|
|
|
|
readSpec = Spec.describe "read" do
|
|
|
|
Spec.it "returns the body of the Request" do
|
|
|
|
let req = SpecHelpers.mockRequest "GET" "" "test" StrMap.empty
|
|
|
|
request <- EffClass.liftEff req
|
|
|
|
body <- Body.read request
|
|
|
|
body `Assertions.shouldEqual` "test"
|
|
|
|
|
2017-07-17 23:42:13 +00:00
|
|
|
writeSpec :: SpecHelpers.Test
|
|
|
|
writeSpec = Spec.describe "write" do
|
|
|
|
Spec.it "writes the string to the Response body" do
|
|
|
|
body <- EffClass.liftEff do
|
|
|
|
resp <- SpecHelpers.mockResponse
|
|
|
|
Body.write resp "test"
|
|
|
|
pure $ SpecHelpers.getResponseBody resp
|
|
|
|
body `Assertions.shouldEqual` "test"
|
|
|
|
|
2017-07-14 06:28:57 +00:00
|
|
|
bodySpec :: SpecHelpers.Test
|
|
|
|
bodySpec = Spec.describe "Body" do
|
2017-07-18 05:25:14 +00:00
|
|
|
readSpec
|
2017-07-17 23:42:13 +00:00
|
|
|
writeSpec
|