purescript-httpurple/test/Test/HTTPure/BodySpec.purs
2017-10-26 17:19:30 -04:00

33 lines
825 B
Haskell

module Test.HTTPure.BodySpec where
import Prelude
import Control.Monad.Eff.Class as EffClass
import Test.Spec as Spec
import HTTPure.Body as Body
import Test.HTTPure.TestHelpers as TestHelpers
import Test.HTTPure.TestHelpers ((?=))
readSpec :: TestHelpers.Test
readSpec = Spec.describe "read" do
Spec.it "is the body of the Request" do
request <- TestHelpers.mockRequest "GET" "" "test" []
body <- Body.read request
body ?= "test"
writeSpec :: TestHelpers.Test
writeSpec = Spec.describe "write" do
Spec.it "writes the string to the Response body" do
body <- EffClass.liftEff do
resp <- TestHelpers.mockResponse
Body.write resp "test"
pure $ TestHelpers.getResponseBody resp
body ?= "test"
bodySpec :: TestHelpers.Test
bodySpec = Spec.describe "Body" do
readSpec
writeSpec