@@ -14,6 +14,8 @@ import Data.Text (Text, unpack)
1414import Test.Hspec
1515import Test.QuickCheck
1616
17+import GHC.Exts (fromList)
18+
1719import Web.Internal.FormUrlEncoded
1820import Web.Internal.HttpApiData
1921import Web.Internal.TestInstances
@@ -35,8 +37,8 @@ genericSpec = describe "Default (generic) instances" $ do
3537
3638 it "contains the correct record values" $ property $ \(x :: SimpleRec) -> do
3739 let f = unForm $ toForm x
38− M.lookup "rec1" f `shouldBe` Just (rec1 x)
39− (parseUrlPiece <$> M.lookup "rec2" f) `shouldBe` Just (Right $ rec2 x)
40+ M.lookup "rec1" f `shouldBe` Just [rec1 x]
41+ (parseQueryParams <$> M.lookup "rec2" f) `shouldBe` Just (Right [rec2 x])
4042
4143 context "for sum types" $ do
4244
@@ -44,11 +46,11 @@ genericSpec = describe "Default (generic) instances" $ do
4446 let f = unForm $ toForm x
4547 case x of
4648 SSRLeft _ _ -> do
47− parseUrlPiece <$> M.lookup "left1" f `shouldBe` Just (Right $ left1 x)
48− parseUrlPiece <$> M.lookup "left2" f `shouldBe` Just (Right $ left2 x)
49+ parseQueryParams <$> M.lookup "left1" f `shouldBe` Just (Right [left1 x])
50+ parseQueryParams <$> M.lookup "left2" f `shouldBe` Just (Right [left2 x])
4951 SSRRight _ _ -> do
50− parseUrlPiece <$> M.lookup "right1" f `shouldBe` Just (Right $ right1 x)
51− parseUrlPiece <$> M.lookup "right2" f `shouldBe` Just (Right $ right2 x)
52+ parseQueryParams <$> M.lookup "right1" f `shouldBe` Just (Right [right1 x])
53+ parseQueryParams <$> M.lookup "right2" f `shouldBe` Just (Right [right2 x])
5254
5355
5456 context "FromForm" $ do
@@ -59,15 +61,15 @@ genericSpec = describe "Default (generic) instances" $ do
5961 fromForm (toForm y) `shouldBe` Right y
6062
6163 it "is the right inverse of ToForm" $ property $ \x (y :: Int) -> do
62− let f1 = Form $ M.fromList [("rec1", x), ("rec2", toUrlPiece y)]
64+ let f1 = fromList [("rec1", x), ("rec2", toQueryParam y)]
6365 Right r1 = fromForm f1 :: Either Text SimpleRec
6466 toForm r1 `shouldBe` f1
65− let f2 = Form $ M.fromList [("right1", x), ("right2", toUrlPiece y)]
67+ let f2 = fromList [("right1", x), ("right2", toQueryParam y)]
6668 Right r2 = fromForm f2 :: Either Text SimpleSumRec
6769 toForm r2 `shouldBe` f2
6870
6971 it "returns the underlying error" $ do
70− let f = Form $ M.fromList [("rec1", "anything"), ("rec2", "bad")]
72+ let f = fromList [("rec1", "anything"), ("rec2", "bad")]
7173 Left e = fromForm f :: Either Text SimpleRec
7274 unpack e `shouldContain` "input does not start with a digit"
7375