2017-10-26 21:19:30 +00:00
|
|
|
module Test.HTTPure.BodySpec where
|
2017-07-14 06:28:57 +00:00
|
|
|
|
2017-07-18 05:31:46 +00:00
|
|
|
import Prelude
|
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-14 06:28:57 +00:00
|
|
|
import Test.Spec as Spec
|
2017-07-17 23:42:13 +00:00
|
|
|
|
|
|
|
import HTTPure.Body as Body
|
2017-07-14 06:28:57 +00:00
|
|
|
|
2017-10-26 21:19:30 +00:00
|
|
|
import Test.HTTPure.TestHelpers as TestHelpers
|
|
|
|
import Test.HTTPure.TestHelpers ((?=))
|
2017-07-14 06:28:57 +00:00
|
|
|
|
2017-10-26 21:19:30 +00:00
|
|
|
readSpec :: TestHelpers.Test
|
2017-07-18 05:25:14 +00:00
|
|
|
readSpec = Spec.describe "read" do
|
2017-09-26 06:08:07 +00:00
|
|
|
Spec.it "is the body of the Request" do
|
2017-10-26 21:19:30 +00:00
|
|
|
request <- TestHelpers.mockRequest "GET" "" "test" []
|
2017-07-18 05:25:14 +00:00
|
|
|
body <- Body.read request
|
2017-07-19 05:36:56 +00:00
|
|
|
body ?= "test"
|
2017-07-18 05:25:14 +00:00
|
|
|
|
2017-10-26 21:19:30 +00:00
|
|
|
writeSpec :: TestHelpers.Test
|
2017-07-17 23:42:13 +00:00
|
|
|
writeSpec = Spec.describe "write" do
|
|
|
|
Spec.it "writes the string to the Response body" do
|
|
|
|
body <- EffClass.liftEff do
|
2017-10-26 21:19:30 +00:00
|
|
|
resp <- TestHelpers.mockResponse
|
2017-07-17 23:42:13 +00:00
|
|
|
Body.write resp "test"
|
2017-10-26 21:19:30 +00:00
|
|
|
pure $ TestHelpers.getResponseBody resp
|
2017-07-19 05:36:56 +00:00
|
|
|
body ?= "test"
|
2017-07-17 23:42:13 +00:00
|
|
|
|
2017-10-26 21:19:30 +00:00
|
|
|
bodySpec :: TestHelpers.Test
|
2017-07-14 06:28:57 +00:00
|
|
|
bodySpec = Spec.describe "Body" do
|
2017-07-18 05:25:14 +00:00
|
|
|
readSpec
|
2017-07-17 23:42:13 +00:00
|
|
|
writeSpec
|