summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--tests/Hakyll/Core/Compiler/Tests.hs35
-rw-r--r--tests/TestSuite.hs5
2 files changed, 39 insertions, 1 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")
+ ]
diff --git a/tests/TestSuite.hs b/tests/TestSuite.hs
index 70ebe98..4eb657b 100644
--- a/tests/TestSuite.hs
+++ b/tests/TestSuite.hs
@@ -2,6 +2,7 @@ module Main where
import Test.Framework (defaultMain, testGroup)
+import qualified Hakyll.Core.Compiler.Tests
import qualified Hakyll.Core.DependencyAnalyzer.Tests
import qualified Hakyll.Core.Identifier.Tests
import qualified Hakyll.Core.Routes.Tests
@@ -19,7 +20,9 @@ import qualified Hakyll.Web.Util.Html.Tests
main :: IO ()
main = defaultMain
- [ testGroup "Hakyll.Core.DependencyAnalyzer.Tests"
+ [ testGroup "Hakyll.Core.Compiler.Tests"
+ Hakyll.Core.Compiler.Tests.tests
+ , testGroup "Hakyll.Core.DependencyAnalyzer.Tests"
Hakyll.Core.DependencyAnalyzer.Tests.tests
, testGroup "Hakyll.Core.Identifier.Tests"
Hakyll.Core.Identifier.Tests.tests