2014-08-10 15:33:18 +02:00
|
|
|
module Tests.Readers.EPUB (tests) where
|
|
|
|
|
|
|
|
import Text.Pandoc.Options
|
|
|
|
import Test.Framework
|
|
|
|
import Test.HUnit (assertBool)
|
|
|
|
import Test.Framework.Providers.HUnit
|
|
|
|
import qualified Data.ByteString.Lazy as BL
|
|
|
|
import Text.Pandoc.Readers.EPUB
|
|
|
|
import Text.Pandoc.MediaBag (MediaBag, mediaDirectory)
|
2015-02-18 20:57:48 +01:00
|
|
|
import Text.Pandoc.Error
|
2014-08-10 15:33:18 +02:00
|
|
|
|
|
|
|
getMediaBag :: FilePath -> IO MediaBag
|
2015-02-18 20:57:48 +01:00
|
|
|
getMediaBag fp = snd . handleError . readEPUB def <$> BL.readFile fp
|
2014-08-10 15:33:18 +02:00
|
|
|
|
|
|
|
testMediaBag :: FilePath -> [(String, String, Int)] -> IO ()
|
|
|
|
testMediaBag fp bag = do
|
|
|
|
actBag <- (mediaDirectory <$> getMediaBag fp)
|
|
|
|
assertBool (show "MediaBag did not match:\nExpected: "
|
|
|
|
++ show bag
|
|
|
|
++ "\nActual: "
|
|
|
|
++ show actBag)
|
|
|
|
(actBag == bag)
|
|
|
|
|
|
|
|
featuresBag :: [(String, String, Int)]
|
2015-04-23 02:38:59 +02:00
|
|
|
featuresBag = [("img/check.gif","image/gif",1340)
|
|
|
|
,("img/check.jpg","image/jpeg",2661)
|
|
|
|
,("img/check.png","image/png",2815)
|
|
|
|
,("img/multiscripts_and_greek_alphabet.png","image/png",10060)
|
|
|
|
]
|
2014-08-10 15:33:18 +02:00
|
|
|
|
|
|
|
tests :: [Test]
|
|
|
|
tests =
|
|
|
|
[ testGroup "EPUB Mediabag"
|
|
|
|
[ testCase "features bag"
|
2014-09-25 14:33:25 +02:00
|
|
|
(testMediaBag "epub/img.epub" featuresBag)
|
2014-08-10 15:33:18 +02:00
|
|
|
]
|
|
|
|
]
|