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 +++++++++++++++++++++++++++ 2 files changed, 105 insertions(+) create mode 100644 tests/Hakyll/Web/Html/RelativizeUrls/Tests.hs create mode 100644 tests/Hakyll/Web/Html/Tests.hs (limited to 'tests/Hakyll/Web/Html') 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" + ] + ] -- cgit v1.2.3