module PandocSpec where import TestImport import Utils.Print import qualified Data.Map.Lazy as Map import Text.Pandoc import Text.Pandoc.Arbitrary () -- For Lens Check _Meta required: --instance CoArbitrary Inline --instance CoArbitrary MetaValue --instance CoArbitrary Meta --instance Function Inline --instance Function MetaValue --instance Function Meta spec :: Spec spec = -- do describe "addMeta" $ do it "should overwrite existing settings" $ do (metaOverwrite, pd) <- generate arbitrary let (Pandoc newMeta _) = addMeta metaOverwrite pd Map.toList (unMeta newMeta) `shouldContain` Map.toList (unMeta metaOverwrite) it "should preserve untouched settings" $ do (metaOverwrite, pd) <- generate arbitrary let (Pandoc keptMeta _) = pd (Pandoc newMeta _) = addMeta metaOverwrite pd Map.toList (unMeta newMeta) `shouldContain` Map.toList (unMeta keptMeta `Map.difference` unMeta metaOverwrite) it "should preserve document block" $ do (metaOverwrite, pd) <- generate arbitrary let (Pandoc _ oldBlocks) = pd (Pandoc _ newBlocks) = addMeta metaOverwrite pd oldBlocks `shouldBe` newBlocks -- describe "_Meta" . it "is a lens" . property $ isLens _Meta