purescript-httpurple/test/Test/HTTPure/PathSpec.purs
Thomas Honeyman 42bf4475e0
Update for PureScript 0.15 (#194)
* Update shell and packages

* Fix code for 0.15

* Fix tests

* Format

* Add check-pulp command

* Generate bowerfile

* Add check-pulp to CI

* Add nixfmt to formatting

* Fixup test helpers

* Take 2

* PR comments (#1)

* Nix cleanup from PR

* Use arrows functions

* Remove unnecessary step

Co-authored-by: Connor Prussin <connor@prussin.net>
2022-05-04 14:02:29 -07:00

40 lines
1.3 KiB
Haskell

module Test.HTTPure.PathSpec where
import Prelude
import HTTPure.Path (read)
import Test.HTTPure.TestHelpers (Test, mockRequest, (?=))
import Test.Spec (describe, it)
readSpec :: Test
readSpec =
describe "read" do
describe "with a query string" do
it "is just the path" do
request <- mockRequest "" "GET" "test/path?blabla" "" []
read request ?= [ "test", "path" ]
describe "with no query string" do
it "is the path" do
request <- mockRequest "" "GET" "test/path" "" []
read request ?= [ "test", "path" ]
describe "with no segments" do
it "is an empty array" do
request <- mockRequest "" "GET" "" "" []
read request ?= []
describe "with empty segments" do
it "strips the empty segments" do
request <- mockRequest "" "GET" "//test//path///?query" "" []
read request ?= [ "test", "path" ]
describe "with percent encoded segments" do
it "decodes percent encoding" do
request <- mockRequest "" "GET" "/test%20path/%2Fthis" "" []
read request ?= [ "test path", "/this" ]
it "does not decode a plus sign" do
request <- mockRequest "" "GET" "/test+path/this" "" []
read request ?= [ "test+path", "this" ]
pathSpec :: Test
pathSpec =
describe "Path" do
readSpec