fix(test): test for applyMetas handles duplicate keys in correct order now

This commit is contained in:
Steffen Jost 2023-01-20 14:29:36 +01:00
parent 45e58f7fa9
commit 0366f8ccca

View File

@ -19,10 +19,10 @@ import Text.Pandoc.Arbitrary ()
-- Instance Arbitrary Meta is somewhat useless, as it always generates the same 3 keys.
newtype ArbitraryMeta = ArbitraryMeta { unArbitraryMeta :: Meta }
deriving newtype (Eq, Ord, Semigroup, Monoid, Show, Read)
deriving newtype (Eq, Ord, Semigroup, Monoid, Show, Read, Typeable)
newtype ArbitraryPandoc = ArbitraryPandoc { unArbitraryPandoc :: Pandoc }
deriving newtype (Eq, Ord, Show, Read)
deriving newtype (Eq, Ord, Show, Read, Typeable)
newtype ArbitraryMapText a = ArbitraryMapText { unArbitraryMapText :: [(Text, a)] }
@ -75,9 +75,8 @@ spec = do
metaList1 :: [(Text, Maybe MetaValue)] = second (Just . MetaString) <$> unArbitraryMapText metaList0
pd = unArbitraryPandoc apd
(Pandoc metaNew _) = applyMetas metaList1 pd
metaMap1 = Map.fromList metaList1 -- remove duplicate keys
keys1 = Map.keysSet metaMap1
metaList' = [(k, Just t) | (k, t) <- mlist metaNew, k `Set.member` keys1]
metaMap1 = Map.fromList $ reverse metaList1 -- remove duplicate keys, keeping the first
metaList' = [(k, Just t) | (k, t) <- mlist metaNew, k `Set.member` metaMap1]
metaList' `shouldMatchList` Map.toAscList metaMap1
it "should preserve untouched settings" $ do