2017-10-26 21:19:30 +00:00
|
|
|
module Test.HTTPure.PathSpec where
|
2017-07-14 06:28:57 +00:00
|
|
|
|
2017-07-18 05:31:46 +00:00
|
|
|
import Prelude
|
2017-07-14 06:28:57 +00:00
|
|
|
|
|
|
|
import Test.Spec as Spec
|
|
|
|
|
2017-09-26 06:08:07 +00:00
|
|
|
import HTTPure.Path as Path
|
|
|
|
|
2017-10-26 21:19:30 +00:00
|
|
|
import Test.HTTPure.TestHelpers as TestHelpers
|
|
|
|
import Test.HTTPure.TestHelpers ((?=))
|
2017-09-26 06:08:07 +00:00
|
|
|
|
2017-10-26 21:19:30 +00:00
|
|
|
readSpec :: TestHelpers.Test
|
2017-09-26 06:08:07 +00:00
|
|
|
readSpec = Spec.describe "read" do
|
|
|
|
Spec.describe "with a query string" do
|
|
|
|
Spec.it "is just the path" do
|
2019-04-25 17:13:04 +00:00
|
|
|
request <- TestHelpers.mockRequest "" "GET" "test/path?blabla" "" []
|
2017-09-26 06:08:07 +00:00
|
|
|
Path.read request ?= [ "test", "path" ]
|
|
|
|
Spec.describe "with no query string" do
|
|
|
|
Spec.it "is the path" do
|
2019-04-25 17:13:04 +00:00
|
|
|
request <- TestHelpers.mockRequest "" "GET" "test/path" "" []
|
2017-09-26 06:08:07 +00:00
|
|
|
Path.read request ?= [ "test", "path" ]
|
|
|
|
Spec.describe "with no segments" do
|
|
|
|
Spec.it "is an empty array" do
|
2019-04-25 17:13:04 +00:00
|
|
|
request <- TestHelpers.mockRequest "" "GET" "" "" []
|
2017-09-26 06:08:07 +00:00
|
|
|
Path.read request ?= []
|
|
|
|
Spec.describe "with empty segments" do
|
|
|
|
Spec.it "strips the empty segments" do
|
2019-04-25 17:13:04 +00:00
|
|
|
request <- TestHelpers.mockRequest "" "GET" "//test//path///?query" "" []
|
2017-09-26 06:08:07 +00:00
|
|
|
Path.read request ?= [ "test", "path" ]
|
2018-11-06 17:45:37 +00:00
|
|
|
Spec.describe "with percent encoded segments" do
|
|
|
|
Spec.it "decodes percent encoding" do
|
2019-04-25 17:13:04 +00:00
|
|
|
request <- TestHelpers.mockRequest "" "GET" "/test%20path/%2Fthis" "" []
|
2018-11-06 17:45:37 +00:00
|
|
|
Path.read request ?= [ "test path", "/this" ]
|
|
|
|
Spec.it "does not decode a plus sign" do
|
2019-04-25 17:13:04 +00:00
|
|
|
request <- TestHelpers.mockRequest "" "GET" "/test+path/this" "" []
|
2018-11-06 17:45:37 +00:00
|
|
|
Path.read request ?= [ "test+path", "this" ]
|
2017-07-14 06:28:57 +00:00
|
|
|
|
2017-10-26 21:19:30 +00:00
|
|
|
pathSpec :: TestHelpers.Test
|
2017-07-14 06:28:57 +00:00
|
|
|
pathSpec = Spec.describe "Path" do
|
2017-09-26 06:08:07 +00:00
|
|
|
readSpec
|