2017-05-25 19:12:29 +00:00
|
|
|
module HTTPure.ResponseSpec where
|
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
import Prelude (bind, discard, ($))
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
import Control.Monad.Eff.Class as EffClass
|
|
|
|
import Node.Encoding as Encoding
|
|
|
|
import Node.StreamBuffer as StreamBuffer
|
|
|
|
import Test.Spec as Spec
|
|
|
|
import Test.Spec.Assertions as Assertions
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
import HTTPure.SpecHelpers as SpecHelpers
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
import HTTPure.Response as Response
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
writeSpec :: SpecHelpers.Test
|
|
|
|
writeSpec = Spec.describe "write" $
|
|
|
|
Spec.it "sets the response body" do
|
|
|
|
body <- EffClass.liftEff do
|
|
|
|
buf <- StreamBuffer.writable
|
|
|
|
Response.write (SpecHelpers.mockResponse buf) "test"
|
|
|
|
StreamBuffer.contents Encoding.UTF8 buf
|
|
|
|
body `Assertions.shouldEqual` "test"
|
|
|
|
|
|
|
|
responseSpec :: SpecHelpers.Test
|
|
|
|
responseSpec = Spec.describe "Response" $
|
2017-05-25 19:12:29 +00:00
|
|
|
writeSpec
|