purescript-httpurple/Test/HTTPure/ResponseSpec.purs

27 lines
742 B
Haskell
Raw Normal View History

module HTTPure.ResponseSpec where
2017-07-10 10:17:13 +00:00
import Prelude (bind, discard, ($))
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-07-10 10:17:13 +00:00
import HTTPure.SpecHelpers as SpecHelpers
2017-07-10 10:17:13 +00:00
import HTTPure.Response as Response
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" $
writeSpec