aboutsummaryrefslogtreecommitdiff
path: root/tests/Tests
diff options
context:
space:
mode:
authorMatthew Pickering <matthewtpickering@gmail.com>2014-08-10 14:33:18 +0100
committerMatthew Pickering <matthewtpickering@gmail.com>2014-08-10 14:58:53 +0100
commitf33ae631f336b25ad3a8fc34f3d09dbbc6b420f5 (patch)
tree4dfe514a4a7e1082d006178848a8f2b85c8a8f97 /tests/Tests
parent7ec8dd956f253613510695b5e971eae71d2f5287 (diff)
downloadpandoc-f33ae631f336b25ad3a8fc34f3d09dbbc6b420f5.tar.gz
Improved EPUB Tests
Rewrote features test to remove all unimplemented features. There are now all three examples of where an image can be included in the test. 1. Cover image 2. As a spine elemnt 3. In the document Tests have also been added to make sure that the mediabag contains all these images after processing.
Diffstat (limited to 'tests/Tests')
-rw-r--r--tests/Tests/Readers/EPUB.hs33
1 files changed, 33 insertions, 0 deletions
diff --git a/tests/Tests/Readers/EPUB.hs b/tests/Tests/Readers/EPUB.hs
new file mode 100644
index 000000000..01b68082b
--- /dev/null
+++ b/tests/Tests/Readers/EPUB.hs
@@ -0,0 +1,33 @@
+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 Control.Applicative
+
+getMediaBag :: FilePath -> IO MediaBag
+getMediaBag fp = snd . readEPUB def <$> BL.readFile fp
+
+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/ElementaryMathExample.png","image/png",1331),("img/Maghreb1.png","image/png",2520),("img/check.gif","image/gif",1340),("img/check.jpg","image/jpeg",2661),("img/check.png","image/png",2815),("img/cichons_diagram.png","image/png",7045),("img/complex_number.png","image/png",5238),("img/multiscripts_and_greek_alphabet.png","image/png",10060)]
+
+tests :: [Test]
+tests =
+ [ testGroup "EPUB Mediabag"
+ [ testCase "features bag"
+ (testMediaBag "epub.features.epub" featuresBag)
+ ]
+ ]