@@ -41,33 +41,12 @@ genericSpec = describe "Default (generic) instances" $ do
41 HashMap.lookup "rec1" f `shouldBe` Just [rec1 x]
41 HashMap.lookup "rec1" f `shouldBe` Just [rec1 x]
42 (parseQueryParams <$> HashMap.lookup "rec2" f) `shouldBe` Just (Right [rec2 x])
42 (parseQueryParams <$> HashMap.lookup "rec2" f) `shouldBe` Just (Right [rec2 x])
44− context "for sum types" $ do
46− it "contains the correct records" $ property $ \x -> do
47− let f = unForm $ toForm x
50− parseQueryParams <$> HashMap.lookup "left1" f `shouldBe` Just (Right [left1 x])
51− parseQueryParams <$> HashMap.lookup "left2" f `shouldBe` Just (Right [left2 x])
53− parseQueryParams <$> HashMap.lookup "right1" f `shouldBe` Just (Right [right1 x])
54− parseQueryParams <$> HashMap.lookup "right2" f `shouldBe` Just (Right [right2 x])
57 context "FromForm" $ do
44 context "FromForm" $ do
59− it "is the left inverse of ToForm" $ property $
60− \(x :: SimpleRec, y :: SimpleSumRec) -> do
61− fromForm (toForm x) `shouldBe` Right x
62− fromForm (toForm y) `shouldBe` Right y
64 it "is the right inverse of ToForm" $ property $ \x (y :: Int) -> do
46 it "is the right inverse of ToForm" $ property $ \x (y :: Int) -> do
65 let f1 = fromList [("rec1", x), ("rec2", toQueryParam y)]
47 let f1 = fromList [("rec1", x), ("rec2", toQueryParam y)]
66 Right r1 = fromForm f1 :: Either Text SimpleRec
48 Right r1 = fromForm f1 :: Either Text SimpleRec
67 toForm r1 `shouldBe` f1
49 toForm r1 `shouldBe` f1
68− let f2 = fromList [("right1", x), ("right2", toQueryParam y)]
69− Right r2 = fromForm f2 :: Either Text SimpleSumRec
70− toForm r2 `shouldBe` f2
72 it "returns the underlying error" $ do
51 it "returns the underlying error" $ do
73 let f = fromList [("rec1", "anything"), ("rec2", "bad")]
52 let f = fromList [("rec1", "anything"), ("rec2", "bad")]