test(pandoc): add more tests for pandoc helper functions

This commit is contained in:
Steffen Jost 2022-07-14 18:20:57 +02:00
parent 9fa12dc758
commit 8b14cd6c4c

View File

@ -11,17 +11,28 @@ import Text.Pandoc.Arbitrary
spec :: Spec spec :: Spec
spec = describe "addMeta" $ do spec = do
it "should overwrite existing settings" $ do describe "addMeta" $ do
metaOverwrite <- arbitrary it "should overwrite existing settings" $ do
pd <- arbitrary metaOverwrite <- arbitrary
let (Pandoc newMeta _) = addMeta metaOverwrite pd pd <- arbitrary
Map.toList newMeta `shouldContain` Map.toList metaOverwrite let (Pandoc newMeta _) = addMeta metaOverwrite pd
Map.toList newMeta `shouldContain` Map.toList metaOverwrite
it "should preserve untouched settings" $ do it "should preserve untouched settings" $ do
metaOverwrite <- arbitrary metaOverwrite <- arbitrary
pd <- arbitrary pd <- arbitrary
let let
(Pandoc keptMeta _) = pd (Pandoc keptMeta _) = pd
(Pandoc newMeta _) = addMeta metaOverwrite pd (Pandoc newMeta _) = addMeta metaOverwrite pd
Map.toList newMeta `shouldContain` Map.toList (keptMeta `Map.difference` metaOverwrite) Map.toList newMeta `shouldContain` Map.toList (keptMeta `Map.difference` metaOverwrite)
it "should preserve document block" $ do
metaOverwrite <- arbitrary
pd <- arbitrary
let
(Pandoc _ oldBlocks) = pd
(Pandoc - newBlocks) = addMeta metaOverwrite pd
oldBlocks `shouldBe` newBlocks
describe "_Meta" . it "is a lens" . property $ isLens _Meta