From 69ffbe03563cdbc7be6b826e2def2fc797442792 Mon Sep 17 00:00:00 2001 From: Jasper Van der Jeugt Date: Tue, 25 Dec 2012 22:49:17 +0100 Subject: Add demoteHeaders, refactor a bit --- tests/Hakyll/Web/Html/RelativizeUrls/Tests.hs | 34 +++++++++++++ tests/Hakyll/Web/Html/Tests.hs | 71 +++++++++++++++++++++++++++ tests/Hakyll/Web/Urls/Relativize/Tests.hs | 34 ------------- tests/Hakyll/Web/Urls/Tests.hs | 55 --------------------- tests/Hakyll/Web/Util/Html/Tests.hs | 29 ----------- tests/TestSuite.hs | 12 ++--- 6 files changed, 110 insertions(+), 125 deletions(-) create mode 100644 tests/Hakyll/Web/Html/RelativizeUrls/Tests.hs create mode 100644 tests/Hakyll/Web/Html/Tests.hs delete mode 100644 tests/Hakyll/Web/Urls/Relativize/Tests.hs delete mode 100644 tests/Hakyll/Web/Urls/Tests.hs delete mode 100644 tests/Hakyll/Web/Util/Html/Tests.hs (limited to 'tests') diff --git a/tests/Hakyll/Web/Html/RelativizeUrls/Tests.hs b/tests/Hakyll/Web/Html/RelativizeUrls/Tests.hs new file mode 100644 index 0000000..7799217 --- /dev/null +++ b/tests/Hakyll/Web/Html/RelativizeUrls/Tests.hs @@ -0,0 +1,34 @@ +-------------------------------------------------------------------------------- +{-# LANGUAGE OverloadedStrings #-} +module Hakyll.Web.Html.RelativizeUrls.Tests + ( tests + ) where + + +-------------------------------------------------------------------------------- +import Test.Framework (Test, testGroup) +import Test.HUnit ((@=?)) + +-------------------------------------------------------------------------------- +import Hakyll.Web.Html.RelativizeUrls +import TestSuite.Util + + +-------------------------------------------------------------------------------- +tests :: Test +tests = testGroup "Hakyll.Web.Html.RelativizeUrls.Tests" $ + fromAssertions "relativizeUrls" + [ "bar" @=? + relativizeUrlsWith ".." "bar" + , "" @=? + relativizeUrlsWith "../.." "" + , "Haskell" @=? + relativizeUrlsWith "../.." + "Haskell" + , "Haskell" @=? + relativizeUrlsWith "../.." + "Haskell" + , "" @=? + relativizeUrlsWith "../.." + "" + ] diff --git a/tests/Hakyll/Web/Html/Tests.hs b/tests/Hakyll/Web/Html/Tests.hs new file mode 100644 index 0000000..35ffe27 --- /dev/null +++ b/tests/Hakyll/Web/Html/Tests.hs @@ -0,0 +1,71 @@ +-------------------------------------------------------------------------------- +module Hakyll.Web.Html.Tests + ( tests + ) where + + +-------------------------------------------------------------------------------- +import Data.Char (toUpper) +import Test.Framework (Test, testGroup) +import Test.HUnit (assert, (@=?)) + + +-------------------------------------------------------------------------------- +import Hakyll.Web.Html +import TestSuite.Util + + +-------------------------------------------------------------------------------- +tests :: Test +tests = testGroup "Hakyll.Web.Html.Tests" $ concat + [ fromAssertions "demoteHeaders" + [ "

A h1 title

" @=? + demoteHeaders "

A h1 title

" + ] + + , fromAssertions "withUrls" + [ "bar" @=? + withUrls (map toUpper) "bar" + , "" @=? + withUrls (map toUpper) "" + + -- Test escaping + , "" @=? + withUrls id "" + , "<stdio>" @=? + withUrls id "<stdio>" + , "" @=? + withUrls id "" + ] + + , 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")) + ] + + , fromAssertions "stripTags" + [ "foo" @=? stripTags "

foo

" + , "foo bar" @=? stripTags "

foo

bar" + , "foo" @=? stripTags "

foo" + ] + ] diff --git a/tests/Hakyll/Web/Urls/Relativize/Tests.hs b/tests/Hakyll/Web/Urls/Relativize/Tests.hs deleted file mode 100644 index 802a1ca..0000000 --- a/tests/Hakyll/Web/Urls/Relativize/Tests.hs +++ /dev/null @@ -1,34 +0,0 @@ --------------------------------------------------------------------------------- -{-# LANGUAGE OverloadedStrings #-} -module Hakyll.Web.Urls.Relativize.Tests - ( tests - ) where - - --------------------------------------------------------------------------------- -import Test.Framework (Test, testGroup) -import Test.HUnit ((@=?)) - --------------------------------------------------------------------------------- -import Hakyll.Web.Urls.Relativize -import TestSuite.Util - - --------------------------------------------------------------------------------- -tests :: Test -tests = testGroup "Hakyll.Web.Urls.Relativize.Tests" $ - fromAssertions "relativizeUrls" - [ "bar" @=? - relativizeUrlsWith ".." "bar" - , "" @=? - relativizeUrlsWith "../.." "" - , "Haskell" @=? - relativizeUrlsWith "../.." - "Haskell" - , "Haskell" @=? - relativizeUrlsWith "../.." - "Haskell" - , "" @=? - relativizeUrlsWith "../.." - "" - ] diff --git a/tests/Hakyll/Web/Urls/Tests.hs b/tests/Hakyll/Web/Urls/Tests.hs deleted file mode 100644 index 648f308..0000000 --- a/tests/Hakyll/Web/Urls/Tests.hs +++ /dev/null @@ -1,55 +0,0 @@ --------------------------------------------------------------------------------- -module Hakyll.Web.Urls.Tests - ( tests - ) where - - --------------------------------------------------------------------------------- -import Data.Char (toUpper) -import Test.Framework (Test, testGroup) -import Test.HUnit (assert, (@=?)) - - --------------------------------------------------------------------------------- -import Hakyll.Web.Urls -import TestSuite.Util - - --------------------------------------------------------------------------------- -tests :: Test -tests = testGroup "Hakyll.Web.Urls.Tests" $ concat - [ fromAssertions "withUrls" - [ "bar" @=? - withUrls (map toUpper) "bar" - , "" @=? - withUrls (map toUpper) "" - - -- Test escaping - , "" @=? - withUrls id "" - , "<stdio>" @=? - withUrls id "<stdio>" - , "" @=? - withUrls id "" - ] - - , 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/Html/Tests.hs b/tests/Hakyll/Web/Util/Html/Tests.hs deleted file mode 100644 index 3a99ca7..0000000 --- a/tests/Hakyll/Web/Util/Html/Tests.hs +++ /dev/null @@ -1,29 +0,0 @@ --------------------------------------------------------------------------------- -module Hakyll.Web.Util.Html.Tests - ( tests - ) where - - --------------------------------------------------------------------------------- -import Test.Framework (Test, testGroup) -import Test.HUnit ((@=?)) - - --------------------------------------------------------------------------------- -import Hakyll.Web.Util.Html -import TestSuite.Util - - --------------------------------------------------------------------------------- -tests :: Test -tests = testGroup "Hakyll.Web.Util.Html" $ concat - [ fromAssertions "stripTags" - [ "foo" @=? stripTags "

foo

" - , "foo bar" @=? stripTags "

foo

bar" - , "foo" @=? stripTags "

foo" - ] - ] diff --git a/tests/TestSuite.hs b/tests/TestSuite.hs index 15eea6d..9be857c 100644 --- a/tests/TestSuite.hs +++ b/tests/TestSuite.hs @@ -5,7 +5,7 @@ module Main -------------------------------------------------------------------------------- -import Test.Framework (defaultMain) +import Test.Framework (defaultMain) -------------------------------------------------------------------------------- @@ -18,11 +18,10 @@ import qualified Hakyll.Core.Runtime.Tests import qualified Hakyll.Core.Store.Tests import qualified Hakyll.Core.UnixFilter.Tests import qualified Hakyll.Core.Util.String.Tests +import qualified Hakyll.Web.Html.RelativizeUrls.Tests +import qualified Hakyll.Web.Html.Tests import qualified Hakyll.Web.Template.Context.Tests import qualified Hakyll.Web.Template.Tests -import qualified Hakyll.Web.Urls.Relativize.Tests -import qualified Hakyll.Web.Urls.Tests -import qualified Hakyll.Web.Util.Html.Tests -------------------------------------------------------------------------------- @@ -37,9 +36,8 @@ main = defaultMain , Hakyll.Core.Store.Tests.tests , Hakyll.Core.UnixFilter.Tests.tests , Hakyll.Core.Util.String.Tests.tests + , Hakyll.Web.Html.RelativizeUrls.Tests.tests + , Hakyll.Web.Html.Tests.tests , Hakyll.Web.Template.Context.Tests.tests , Hakyll.Web.Template.Tests.tests - , Hakyll.Web.Urls.Relativize.Tests.tests - , Hakyll.Web.Urls.Tests.tests - , Hakyll.Web.Util.Html.Tests.tests ] -- cgit v1.2.3