purescript-httpurple/test/Test/HTTPure/PathSpec.purs

41 lines
1.4 KiB
Haskell
Raw Normal View History

2017-10-26 21:19:30 +00:00
module Test.HTTPure.PathSpec where
import Prelude
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
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
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
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
request <- TestHelpers.mockRequest "" "GET" "//test//path///?query" "" []
2017-09-26 06:08:07 +00:00
Path.read request ?= [ "test", "path" ]
Spec.describe "with percent encoded segments" do
Spec.it "decodes percent encoding" do
request <- TestHelpers.mockRequest "" "GET" "/test%20path/%2Fthis" "" []
Path.read request ?= [ "test path", "/this" ]
Spec.it "does not decode a plus sign" do
request <- TestHelpers.mockRequest "" "GET" "/test+path/this" "" []
Path.read request ?= [ "test+path", "this" ]
2017-10-26 21:19:30 +00:00
pathSpec :: TestHelpers.Test
pathSpec = Spec.describe "Path" do
2017-09-26 06:08:07 +00:00
readSpec