purescript-httpurple/test/HTTPure/BodySpec.purs

33 lines
810 B
Haskell
Raw Normal View History

module HTTPure.BodySpec where
import Prelude
import Control.Monad.Eff.Class as EffClass
import Test.Spec as Spec
import HTTPure.Body as Body
import HTTPure.SpecHelpers as SpecHelpers
import HTTPure.SpecHelpers ((?=))
2017-07-18 05:25:14 +00:00
readSpec :: SpecHelpers.Test
readSpec = Spec.describe "read" do
2017-09-26 06:08:07 +00:00
Spec.it "is the body of the Request" do
request <- SpecHelpers.mockRequest "GET" "" "test" []
2017-07-18 05:25:14 +00:00
body <- Body.read request
body ?= "test"
2017-07-18 05:25:14 +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 ?= "test"
bodySpec :: SpecHelpers.Test
bodySpec = Spec.describe "Body" do
2017-07-18 05:25:14 +00:00
readSpec
writeSpec