summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorJasper Van der Jeugt <m@jaspervdj.be>2011-09-06 22:26:07 +0200
committerJasper Van der Jeugt <m@jaspervdj.be>2011-09-06 22:27:53 +0200
commit75f157ca8c319d770f02c38d65226bb3de495a0e (patch)
tree51c92ac2658e3f265dc3971651dd89817f4e6cc9 /tests
parentbf4115eb0fad1a3b7a0ce5dc71b55045df30995b (diff)
downloadhakyll-75f157ca8c319d770f02c38d65226bb3de495a0e.tar.gz
Add some URL utilities
Diffstat (limited to 'tests')
-rw-r--r--tests/Hakyll/Web/Urls/Relativize/Tests.hs (renamed from tests/Hakyll/Web/RelativizeUrls/Tests.hs)4
-rw-r--r--tests/Hakyll/Web/Urls/Tests.hs38
-rw-r--r--tests/Hakyll/Web/Util/Url/Tests.hs25
-rw-r--r--tests/TestSuite.hs12
4 files changed, 46 insertions, 33 deletions
diff --git a/tests/Hakyll/Web/RelativizeUrls/Tests.hs b/tests/Hakyll/Web/Urls/Relativize/Tests.hs
index 05971ad..00f5a0f 100644
--- a/tests/Hakyll/Web/RelativizeUrls/Tests.hs
+++ b/tests/Hakyll/Web/Urls/Relativize/Tests.hs
@@ -1,12 +1,12 @@
{-# LANGUAGE OverloadedStrings #-}
-module Hakyll.Web.RelativizeUrls.Tests
+module Hakyll.Web.Urls.Relativize.Tests
( tests
) where
import Test.Framework
import Test.HUnit hiding (Test)
-import Hakyll.Web.RelativizeUrls
+import Hakyll.Web.Urls.Relativize
import TestSuite.Util
tests :: [Test]
diff --git a/tests/Hakyll/Web/Urls/Tests.hs b/tests/Hakyll/Web/Urls/Tests.hs
new file mode 100644
index 0000000..db7a10b
--- /dev/null
+++ b/tests/Hakyll/Web/Urls/Tests.hs
@@ -0,0 +1,38 @@
+module Hakyll.Web.Urls.Tests
+ ( tests
+ ) where
+
+import Data.Char (toUpper)
+
+import Test.Framework
+import Test.HUnit hiding (Test)
+
+import Hakyll.Web.Urls
+import TestSuite.Util
+
+tests :: [Test]
+tests = concat
+ [ fromAssertions "withUrls"
+ [ "<a href=\"FOO\">bar</a>" @=?
+ withUrls (map toUpper) "<a href=\"foo\">bar</a>"
+ , "<img src=\"OH BAR\">" @=?
+ withUrls (map toUpper) "<img src=\"oh bar\">"
+ ]
+ , fromAssertions "toUrl"
+ [ "/foo/bar.html" @=? toUrl "foo/bar.html"
+ , "/" @=? toUrl "/"
+ , "/funny-pics.html" @=? toUrl "/funny-pics.html"
+ ]
+ , fromAssertions "toSiteRoot"
+ [ ".." @=? toSiteRoot "/foo/bar.html"
+ , "." @=? toSiteRoot "index.html"
+ , "." @=? toSiteRoot "/index.html"
+ , "../.." @=? toSiteRoot "foo/bar/qux"
+ ]
+ , fromAssertions "isExternal"
+ [ assert (isExternal "http://reddit.com")
+ , assert (isExternal "https://mail.google.com")
+ , assert (not (isExternal "../header.png"))
+ , assert (not (isExternal "/foo/index.html"))
+ ]
+ ]
diff --git a/tests/Hakyll/Web/Util/Url/Tests.hs b/tests/Hakyll/Web/Util/Url/Tests.hs
deleted file mode 100644
index aab4172..0000000
--- a/tests/Hakyll/Web/Util/Url/Tests.hs
+++ /dev/null
@@ -1,25 +0,0 @@
-module Hakyll.Web.Util.Url.Tests
- ( tests
- ) where
-
-import Test.Framework
-import Test.HUnit hiding (Test)
-
-import Hakyll.Web.Util.Url
-import TestSuite.Util
-
-tests :: [Test]
-tests = concat
- [ fromAssertions "toUrl"
- [ "/foo/bar.html" @=? toUrl "foo/bar.html"
- , "/" @=? toUrl "/"
- , "/funny-pics.html" @=? toUrl "/funny-pics.html"
- ]
-
- , fromAssertions "toSiteRoot"
- [ ".." @=? toSiteRoot "/foo/bar.html"
- , "." @=? toSiteRoot "index.html"
- , "." @=? toSiteRoot "/index.html"
- , "../.." @=? toSiteRoot "foo/bar/qux"
- ]
- ]
diff --git a/tests/TestSuite.hs b/tests/TestSuite.hs
index 0f13106..fdd5e56 100644
--- a/tests/TestSuite.hs
+++ b/tests/TestSuite.hs
@@ -10,10 +10,10 @@ import qualified Hakyll.Core.Store.Tests
import qualified Hakyll.Core.UnixFilter.Tests
import qualified Hakyll.Web.Page.Tests
import qualified Hakyll.Web.Page.Metadata.Tests
-import qualified Hakyll.Web.RelativizeUrls.Tests
import qualified Hakyll.Web.Template.Tests
+import qualified Hakyll.Web.Urls.Tests
+import qualified Hakyll.Web.Urls.Relativize.Tests
import qualified Hakyll.Web.Util.Html.Tests
-import qualified Hakyll.Web.Util.Url.Tests
main :: IO ()
main = defaultMain
@@ -33,12 +33,12 @@ main = defaultMain
Hakyll.Web.Page.Tests.tests
, testGroup "Hakyll.Web.Page.Metadata.Tests"
Hakyll.Web.Page.Metadata.Tests.tests
- , testGroup "Hakyll.Web.RelativizeUrls.Tests"
- Hakyll.Web.RelativizeUrls.Tests.tests
, testGroup "Hakyll.Web.Template.Tests"
Hakyll.Web.Template.Tests.tests
+ , testGroup "Hakyll.Web.Urls.Tests"
+ Hakyll.Web.Urls.Tests.tests
+ , testGroup "Hakyll.Web.Urls.Relativize.Tests"
+ Hakyll.Web.Urls.Relativize.Tests.tests
, testGroup "Hakyll.Web.Util.Html.Tests"
Hakyll.Web.Util.Html.Tests.tests
- , testGroup "Hakyll.Web.Util.Url.Tests"
- Hakyll.Web.Util.Url.Tests.tests
]