Skip to content

Commit

Permalink
Merge pull request #86 from kaol/overzealous-namespace-warning-test
Browse files Browse the repository at this point in the history
Test for namespace warning message with nested splice use.
  • Loading branch information
mightybyte committed Aug 11, 2016
2 parents b27e744 + 49d4018 commit 9dee34e
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/suite/Heist/Compiled/Tests.hs
Expand Up @@ -41,6 +41,7 @@ tests = [ testCase "compiled/simple" simpleCompiledTest
, testCase "compiled/namespace4" namespaceTest4
, testCase "compiled/namespace5" namespaceTest5
, testCase "compiled/no-ns-splices" noNsSplices
, testCase "compiled/ns-nested" nsNestedUnused
, testCase "compiled/nsbind" nsBindTest
, testCase "compiled/nsbinderr" nsBindErrorTest
, testCase "compiled/nscall" nsCallTest
Expand Down Expand Up @@ -179,6 +180,25 @@ noNsSplices = do
& scTemplateLocations .~ [loadTemplates "templates-no-ns"]


------------------------------------------------------------------------------
-- | Test that no namespace splice message works correctly when there are no
-- top level splices used
nsNestedUnused :: IO ()
nsNestedUnused = do
res <- runExceptT $ do
hs <- ExceptT $ initHeist hc
runner <- noteT ["Error rendering"] $ hoistMaybe $
renderTemplate hs "test"
b <- lift $ fst runner
return $ toByteString b

H.assertEqual "ns nested unused warn test" (Right "<div>aeou</div>\n") res
where
hc = HeistConfig sc "h" False
sc = mempty & scCompiledSplices .~ ("foo" ## return $ yieldPureText "aeou")
& scTemplateLocations .~ [loadTemplates "templates-ns-nested"]


nsBindTemplateHC :: String -> HeistConfig IO
nsBindTemplateHC dir = HeistConfig sc "h" False
where
Expand Down
1 change: 1 addition & 0 deletions test/templates-ns-nested/test.tpl
@@ -0,0 +1 @@
<div><h:foo/></div>

0 comments on commit 9dee34e

Please sign in to comment.