aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/Cana/UtilSpec.hs23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/Cana/UtilSpec.hs b/test/Cana/UtilSpec.hs
index 7a3292a..2ccbf5b 100644
--- a/test/Cana/UtilSpec.hs
+++ b/test/Cana/UtilSpec.hs
@@ -25,3 +25,26 @@ spec = do
applyWhen True (+1) (3 :: Int) `shouldBe` 4
it "doesn't apply a function when False is given" $ do
applyWhen False (+1) (3 :: Int) `shouldBe` 3
+
+ describe "insert" $ do
+ it "works on an empty list" $ do
+ insert "foo" "bar" [] `shouldBe` [("foo", "bar")]
+ it "replaces an existing element" $ do
+ let i = insert "foo" "bar" [("a", "b"), ("foo", "baz"), ("c", "d")]
+ i `shouldContain` [("a", "b")]
+ i `shouldContain` [("foo", "bar")]
+ i `shouldContain` [("c", "d")]
+ length i `shouldBe` 3
+ it "inserts a missing element" $ do
+ let i = insert "foo" "bar" [("a", "b")]
+ i `shouldContain` [("a", "b")]
+ i `shouldContain` [("foo", "bar")]
+ length i `shouldBe` 2
+
+ describe "insertAll" $ do
+ it "inserts all elements" $ do
+ let i = insertAll [("foo", "bar"), ("qux", "baz")] [("a", "b"), ("foo", "gulp")]
+ i `shouldContain` [("foo", "bar")]
+ i `shouldContain` [("qux", "baz")]
+ i `shouldContain` [("a", "b")]
+ length i `shouldBe` 3