purescript-httpurple/test/HTTPure/IntegrationSpec.purs

64 lines
1.8 KiB
Haskell
Raw Normal View History

module HTTPure.IntegrationSpec where
import Prelude
2017-07-10 10:17:13 +00:00
import Control.Monad.Eff.Class as EffClass
2017-07-18 17:09:03 +00:00
import Data.StrMap as StrMap
2017-07-10 10:17:13 +00:00
import Test.Spec as Spec
2017-07-10 10:17:13 +00:00
import HTTPure.SpecHelpers as SpecHelpers
import HTTPure.SpecHelpers ((?=))
2017-07-10 10:17:13 +00:00
2017-07-18 17:09:03 +00:00
import Headers as Headers
2017-07-10 10:17:13 +00:00
import HelloWorld as HelloWorld
import MultiRoute as MultiRoute
2017-07-18 17:09:03 +00:00
import Post as Post
2017-07-23 19:17:02 +00:00
import SSL as SSL
2017-07-18 17:09:03 +00:00
headersSpec :: SpecHelpers.Test
headersSpec = Spec.it "runs the headers example" do
EffClass.liftEff Headers.main
header <- SpecHelpers.getHeader port StrMap.empty "/" "X-Example"
header ?= "hello world!"
response <- SpecHelpers.get port (StrMap.singleton "X-Input" "test") "/"
response ?= "test"
where port = Headers.port
2017-07-10 10:17:13 +00:00
helloWorldSpec :: SpecHelpers.Test
helloWorldSpec = Spec.it "runs the hello world example" do
EffClass.liftEff HelloWorld.main
response <- SpecHelpers.get port StrMap.empty "/"
response ?= "hello world!"
where port = HelloWorld.port
2017-07-10 10:17:13 +00:00
multiRouteSpec :: SpecHelpers.Test
multiRouteSpec = Spec.it "runs the multi route example" do
EffClass.liftEff MultiRoute.main
hello <- SpecHelpers.get port StrMap.empty "/hello"
hello ?= "hello"
goodbye <- SpecHelpers.get port StrMap.empty "/goodbye"
goodbye ?= "goodbye"
where port = MultiRoute.port
2017-07-10 10:17:13 +00:00
2017-07-18 17:09:03 +00:00
postSpec :: SpecHelpers.Test
postSpec = Spec.it "runs the post example" do
EffClass.liftEff Post.main
response <- SpecHelpers.post port StrMap.empty "/" "test"
response ?= "test"
where port = Post.port
2017-07-23 19:17:02 +00:00
sslSpec :: SpecHelpers.Test
sslSpec = Spec.it "runs the ssl example" do
EffClass.liftEff SSL.main
response <- SpecHelpers.get' port StrMap.empty "/"
response ?= "hello world!"
where port = SSL.port
2017-07-10 10:17:13 +00:00
integrationSpec :: SpecHelpers.Test
integrationSpec = Spec.describe "Integration" do
2017-07-18 17:09:03 +00:00
headersSpec
2017-07-10 10:17:13 +00:00
helloWorldSpec
multiRouteSpec
2017-07-18 17:09:03 +00:00
postSpec
2017-07-23 19:17:02 +00:00
sslSpec