From 75f157ca8c319d770f02c38d65226bb3de495a0e Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 6 Sep 2011 22:26:07 +0200 Subject: Add some URL utilities --- tests/Hakyll/Web/RelativizeUrls/Tests.hs | 20 ---------------- tests/Hakyll/Web/Urls/Relativize/Tests.hs | 20 ++++++++++++++++ tests/Hakyll/Web/Urls/Tests.hs | 38 +++++++++++++++++++++++++++++++ tests/Hakyll/Web/Util/Url/Tests.hs | 25 -------------------- 4 files changed, 58 insertions(+), 45 deletions(-) delete mode 100644 tests/Hakyll/Web/RelativizeUrls/Tests.hs create mode 100644 tests/Hakyll/Web/Urls/Relativize/Tests.hs create mode 100644 tests/Hakyll/Web/Urls/Tests.hs delete mode 100644 tests/Hakyll/Web/Util/Url/Tests.hs (limited to 'tests/Hakyll') diff --git a/tests/Hakyll/Web/RelativizeUrls/Tests.hs b/tests/Hakyll/Web/RelativizeUrls/Tests.hs deleted file mode 100644 index 05971ad..0000000 --- a/tests/Hakyll/Web/RelativizeUrls/Tests.hs +++ /dev/null @@ -1,20 +0,0 @@ -{-# LANGUAGE OverloadedStrings #-} -module Hakyll.Web.RelativizeUrls.Tests - ( tests - ) where - -import Test.Framework -import Test.HUnit hiding (Test) - -import Hakyll.Web.RelativizeUrls -import TestSuite.Util - -tests :: [Test] -tests = fromAssertions "relativizeUrls" - [ "bar" @=? - relativizeUrls ".." "bar" - , "" @=? - relativizeUrls "../.." "" - , "Haskell" @=? - relativizeUrls "../.." "Haskell" - ] diff --git a/tests/Hakyll/Web/Urls/Relativize/Tests.hs b/tests/Hakyll/Web/Urls/Relativize/Tests.hs new file mode 100644 index 0000000..00f5a0f --- /dev/null +++ b/tests/Hakyll/Web/Urls/Relativize/Tests.hs @@ -0,0 +1,20 @@ +{-# LANGUAGE OverloadedStrings #-} +module Hakyll.Web.Urls.Relativize.Tests + ( tests + ) where + +import Test.Framework +import Test.HUnit hiding (Test) + +import Hakyll.Web.Urls.Relativize +import TestSuite.Util + +tests :: [Test] +tests = fromAssertions "relativizeUrls" + [ "bar" @=? + relativizeUrls ".." "bar" + , "" @=? + relativizeUrls "../.." "" + , "Haskell" @=? + relativizeUrls "../.." "Haskell" + ] 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" + [ "bar" @=? + withUrls (map toUpper) "bar" + , "" @=? + withUrls (map toUpper) "" + ] + , 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" - ] - ] -- cgit v1.2.3