File tree Expand file tree Collapse file tree 3 files changed +49
-2
lines changed Expand file tree Collapse file tree 3 files changed +49
-2
lines changed Original file line number Diff line number Diff line change @@ -12,7 +12,7 @@ install:
1212 - npm install -g bower
1313 - npm install
1414script :
15- - bower install --production
15+ - bower install
1616 - npm run -s build
1717 - npm run -s test
1818after_success :
Original file line number Diff line number Diff line change 2121 "purescript-strings" : " ^4.0.0" ,
2222 "purescript-tuples" : " ^5.0.0" ,
2323 "purescript-foldable-traversable" : " ^4.1.1"
24+ },
25+ "devDependencies" : {
26+ "purescript-assert" : " ^4.1.0"
2427 }
2528}
Original file line number Diff line number Diff line change @@ -2,7 +2,51 @@ module Test.Main where
22
33import Prelude
44
5+ import Data.FormURLEncoded (FormURLEncoded (..), decode , encode )
6+ import Data.Maybe (Maybe (..))
7+ import Data.Tuple (Tuple (..))
58import Effect (Effect )
9+ import Effect.Console (log )
10+ import Test.Assert (assert )
611
712main :: Effect Unit
8- main = pure unit
13+ main = do
14+
15+ testDecode " a=aa&b=bb" (Just $ FormURLEncoded [ Tuple " a" $ Just " aa" , Tuple " b" $ Just " bb" ])
16+
17+ testDecode " this=this%3Dthis" (Just $ FormURLEncoded [ Tuple " this" $ Just " this=this" ])
18+
19+ testDecode " &x=x&&y=y&z=" $
20+ Just $ FormURLEncoded
21+ [ Tuple " " Nothing
22+ , Tuple " x" $ Just " x"
23+ , Tuple " " Nothing
24+ , Tuple " y" $ Just " y"
25+ , Tuple " z" $ Just " "
26+ ]
27+
28+ testDecode " a=b&%8A=c" Nothing
29+
30+ testEncode (FormURLEncoded [ Tuple " a" $ Just " aa" , Tuple " b" $ Just " bb" ]) $ Just " a=aa&b=bb"
31+
32+ testEncode (FormURLEncoded [ Tuple " this" $ Just " this=this" ]) $ Just " this=this%3Dthis"
33+
34+ testEncode
35+ (FormURLEncoded
36+ [ Tuple " " Nothing
37+ , Tuple " x" $ Just " x"
38+ , Tuple " " Nothing
39+ , Tuple " y" $ Just " y"
40+ , Tuple " z" $ Just " "
41+ ])
42+ (Just " &x=x&&y=y&z=" )
43+
44+ where
45+
46+ testDecode :: String -> Maybe FormURLEncoded -> Effect Unit
47+ testDecode input expected =
48+ (log $ " decode \" " <> input <> " \" == " <> show expected) *> assert (decode input == expected)
49+
50+ testEncode :: FormURLEncoded -> Maybe String -> Effect Unit
51+ testEncode input expected =
52+ (log $ " encode " <> show input <> " == \" " <> show expected <> " \" " ) *> assert (encode input == expected)
You can’t perform that action at this time.
0 commit comments