2017-05-25 19:12:29 +00:00
|
|
|
module HTTPure.RequestSpec where
|
|
|
|
|
2017-07-18 05:31:46 +00:00
|
|
|
import Prelude
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-09-26 06:08:07 +00:00
|
|
|
import Data.Tuple as Tuple
|
2017-07-14 06:28:57 +00:00
|
|
|
import Data.StrMap as StrMap
|
2017-07-10 10:17:13 +00:00
|
|
|
import Test.Spec as Spec
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-18 01:51:43 +00:00
|
|
|
import HTTPure.Headers as Headers
|
2017-09-26 06:08:07 +00:00
|
|
|
import HTTPure.Method as Method
|
2017-07-14 06:28:57 +00:00
|
|
|
import HTTPure.Request as Request
|
|
|
|
|
2017-07-10 10:17:13 +00:00
|
|
|
import HTTPure.SpecHelpers as SpecHelpers
|
2017-07-19 05:21:36 +00:00
|
|
|
import HTTPure.SpecHelpers ((?=))
|
2017-05-25 19:12:29 +00:00
|
|
|
|
2017-07-14 06:28:57 +00:00
|
|
|
fromHTTPRequestSpec :: SpecHelpers.Test
|
|
|
|
fromHTTPRequestSpec = Spec.describe "fromHTTPRequest" do
|
2017-09-26 06:08:07 +00:00
|
|
|
Spec.it "contains the correct method" do
|
|
|
|
mock <- mockRequest
|
|
|
|
mock.method ?= Method.Post
|
|
|
|
Spec.it "contains the correct path" do
|
|
|
|
mock <- mockRequest
|
|
|
|
mock.path ?= [ "test" ]
|
|
|
|
Spec.it "contains the correct query" do
|
|
|
|
mock <- mockRequest
|
2017-09-26 07:14:06 +00:00
|
|
|
mock.query ?= StrMap.singleton "a" "b"
|
2017-09-26 06:08:07 +00:00
|
|
|
Spec.it "contains the correct headers" do
|
|
|
|
mock <- mockRequest
|
|
|
|
mock.headers ?= Headers.headers mockHeaders
|
|
|
|
Spec.it "contains the correct body" do
|
|
|
|
mock <- mockRequest
|
|
|
|
mock.body ?= "body"
|
2017-07-18 01:51:43 +00:00
|
|
|
where
|
2017-09-26 06:08:07 +00:00
|
|
|
mockHeaders = [ Tuple.Tuple "Test" "test" ]
|
|
|
|
mockHTTPRequest =
|
|
|
|
SpecHelpers.mockRequest "POST" "/test?a=b" "body" mockHeaders
|
|
|
|
mockRequest = mockHTTPRequest >>= Request.fromHTTPRequest
|
2017-07-10 10:17:13 +00:00
|
|
|
|
|
|
|
requestSpec :: SpecHelpers.Test
|
2017-07-14 06:28:57 +00:00
|
|
|
requestSpec = Spec.describe "Request" do
|
|
|
|
fromHTTPRequestSpec
|