diff options
author | John MacFarlane <jgm@berkeley.edu> | 2017-02-04 12:56:30 +0100 |
---|---|---|
committer | John MacFarlane <jgm@berkeley.edu> | 2017-02-04 12:56:30 +0100 |
commit | 18ab8642692caca2716fd9b5a0e6dbfd3d9cf9cc (patch) | |
tree | 05f4e9024093e233c131b3494e71265062ffd94a /test/Tests/Readers/EPUB.hs | |
parent | 8418c1a7d7e5312dfddbc011adb257552b2a864b (diff) | |
download | pandoc-18ab8642692caca2716fd9b5a0e6dbfd3d9cf9cc.tar.gz |
Moved tests/ -> test/.
Diffstat (limited to 'test/Tests/Readers/EPUB.hs')
-rw-r--r-- | test/Tests/Readers/EPUB.hs | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/test/Tests/Readers/EPUB.hs b/test/Tests/Readers/EPUB.hs new file mode 100644 index 000000000..9190671c3 --- /dev/null +++ b/test/Tests/Readers/EPUB.hs @@ -0,0 +1,39 @@ +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) +import qualified Text.Pandoc.Class as P + +getMediaBag :: FilePath -> IO MediaBag +getMediaBag fp = do + bs <- BL.readFile fp + snd <$> (P.runIOorExplode $ P.withMediaBag $ readEPUB def bs) + +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)] +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) + ] + +tests :: [Test] +tests = + [ testGroup "EPUB Mediabag" + [ testCase "features bag" + (testMediaBag "epub/img.epub" featuresBag) + ] + ] |