summaryrefslogtreecommitdiff
path: root/tests/Hakyll
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2012-02-13 22:40:11 +0100
committerJasper Van der Jeugt <m@jaspervdj.be>2012-02-13 22:48:13 +0100
commitf5c9c6fa32cd330a0daa4d6cbff9fcae53d317cc (patch)
treea55f7b811ff4cf23f9c958728df4cff594b31b60 /tests/Hakyll
parent75b8c3e0d2d4fb20602e61ef190205dacc9cd5ec (diff)
downloadhakyll-f5c9c6fa32cd330a0daa4d6cbff9fcae53d317cc.tar.gz
Add a test for byExtension
Diffstat (limited to 'tests/Hakyll')
-rw-r--r--tests/Hakyll/Core/Compiler/Tests.hs35
1 files changed, 35 insertions, 0 deletions
diff --git a/tests/Hakyll/Core/Compiler/Tests.hs b/tests/Hakyll/Core/Compiler/Tests.hs
new file mode 100644
index 0000000..7ea7190
--- /dev/null
+++ b/tests/Hakyll/Core/Compiler/Tests.hs
@@ -0,0 +1,35 @@
+{-# LANGUAGE OverloadedStrings #-}
+module Hakyll.Core.Compiler.Tests
+ where
+
+import qualified Data.Map as M
+
+import Test.Framework (Test)
+import Test.Framework.Providers.HUnit (testCase)
+import qualified Test.HUnit as H
+
+import Hakyll.Core.Compiler
+import Hakyll.Core.Resource.Provider.Dummy
+import Hakyll.Core.Util.Arrow
+import TestSuite.Util
+
+tests :: [Test]
+tests =
+ [ testCase "byExtension" byExtensionTest
+ ]
+
+byExtensionTest :: H.Assertion
+byExtensionTest = do
+ provider <- dummyResourceProvider $ M.empty
+ txt <- runCompilerJobTest compiler "foo.txt" provider uni
+ css <- runCompilerJobTest compiler "bar.css" provider uni
+ html <- runCompilerJobTest compiler "qux.html" provider uni
+ H.assertEqual "byExtension" "txt" txt
+ H.assertEqual "byExtension" "css" css
+ H.assertEqual "byExtension" "unknown" html
+ where
+ uni = ["foo.txt", "bar.css", "qux.html"]
+ compiler = byExtension (constA ("unknown" :: String))
+ [ (".txt", constA "txt")
+ , (".css", constA "css")
+ ]