Fix HTTPure.Utils.replacePlus (#166)

* Create failing test.

* Fix code so failing test passes.
This commit is contained in:
Tim McIver 2020-11-14 16:09:07 -05:00 committed by GitHub
parent a81abca2d6
commit b3eb977096
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -19,7 +19,7 @@ encodeURIComponent = unsafeEncodeURIComponent
replacePlus :: String -> String replacePlus :: String -> String
replacePlus = replacePlus =
String.replace (String.Pattern "+") (String.Replacement "%20") String.replaceAll (String.Pattern "+") (String.Replacement "%20")
urlDecode :: String -> String urlDecode :: String -> String

View File

@ -0,0 +1,19 @@
module Test.HTTPure.UtilsSpec where
import Prelude
import Data.Tuple as Tuple
import Foreign.Object as Object
import Test.Spec as Spec
import HTTPure.Query as Query
import HTTPure.Utils as Utils
import Test.HTTPure.TestHelpers as TestHelpers
import Test.HTTPure.TestHelpers ((?=))
utilsSpec :: TestHelpers.Test
utilsSpec = Spec.describe "replacePlus" do
Spec.it "should replace all pluses" do
Utils.replacePlus "HTTPPure+is+A+purescript+HTTP+server+framework" ?=
"HTTPPure%20is%20A%20purescript%20HTTP%20server%20framework"

View File

@ -17,6 +17,7 @@ import Test.HTTPure.RequestSpec as RequestSpec
import Test.HTTPure.ResponseSpec as ResponseSpec import Test.HTTPure.ResponseSpec as ResponseSpec
import Test.HTTPure.ServerSpec as ServerSpec import Test.HTTPure.ServerSpec as ServerSpec
import Test.HTTPure.StatusSpec as StatusSpec import Test.HTTPure.StatusSpec as StatusSpec
import Test.HTTPure.UtilsSpec as UtilsSpec
import Test.HTTPure.VersionSpec as VersionSpec import Test.HTTPure.VersionSpec as VersionSpec
import Test.HTTPure.IntegrationSpec as IntegrationSpec import Test.HTTPure.IntegrationSpec as IntegrationSpec
@ -34,5 +35,6 @@ main = Aff.launchAff_ $ Runner.runSpec [ Reporter.specReporter ] $ Spec.describe
ResponseSpec.responseSpec ResponseSpec.responseSpec
ServerSpec.serverSpec ServerSpec.serverSpec
StatusSpec.statusSpec StatusSpec.statusSpec
UtilsSpec.utilsSpec
VersionSpec.versionSpec VersionSpec.versionSpec
IntegrationSpec.integrationSpec IntegrationSpec.integrationSpec