purescript-httpurple/test/HTTPure/IntegrationSpec.purs

51 lines
1.6 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
import Test.Spec.Assertions as Assertions
2017-07-10 10:17:13 +00:00
import HTTPure.SpecHelpers as SpecHelpers
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
headersSpec :: SpecHelpers.Test
headersSpec = Spec.it "runs the headers example" do
EffClass.liftEff Headers.main
header <- SpecHelpers.getHeader 8082 StrMap.empty "/" "X-Example"
header `Assertions.shouldEqual` "hello world!"
response <- SpecHelpers.get 8082 (StrMap.singleton "X-Input" "test") "/"
response `Assertions.shouldEqual` "test"
2017-07-10 10:17:13 +00:00
helloWorldSpec :: SpecHelpers.Test
helloWorldSpec = Spec.it "runs the hello world example" do
EffClass.liftEff HelloWorld.main
2017-07-18 17:09:03 +00:00
response <- SpecHelpers.get 8080 StrMap.empty "/"
2017-07-10 10:17:13 +00:00
response `Assertions.shouldEqual` "hello world!"
multiRouteSpec :: SpecHelpers.Test
multiRouteSpec = Spec.it "runs the multi route example" do
EffClass.liftEff MultiRoute.main
2017-07-18 17:09:03 +00:00
hello <- SpecHelpers.get 8081 StrMap.empty "/hello"
2017-07-10 10:17:13 +00:00
hello `Assertions.shouldEqual` "hello"
2017-07-18 17:09:03 +00:00
goodbye <- SpecHelpers.get 8081 StrMap.empty "/goodbye"
2017-07-10 10:17:13 +00:00
goodbye `Assertions.shouldEqual` "goodbye"
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 8084 StrMap.empty "/" "test"
response `Assertions.shouldEqual` "test"
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