purescript-httpurple/test/Test/HTTPure/BodySpec.purs
Petri Lehtinen 3e94aa6f9d Support binary response body (#99)
* Support binary response body

Fixes #98

* Address PR comments

- Expose data constructors for Body and use them for construction and
  pattern matching instead of various helpers

- Add an example and integration test for binary response

- Adjust the middleware example to be a bit nicer
2018-08-19 19:50:07 -07:00

33 lines
841 B
Haskell

module Test.HTTPure.BodySpec where
import Prelude
import Effect.Class as EffectClass
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 <- EffectClass.liftEffect do
resp <- TestHelpers.mockResponse
Body.write resp $ Body.StringBody "test"
pure $ TestHelpers.getResponseBody resp
body ?= "test"
bodySpec :: TestHelpers.Test
bodySpec = Spec.describe "Body" do
readSpec
writeSpec