Paragraph testing
This commit is contained in:
parent
135b878233
commit
2e66b03baa
10 changed files with 80 additions and 2 deletions
|
@ -127,4 +127,14 @@ golden input ref = do
|
|||
|
||||
-- @@test Paragraph Smoke
|
||||
smokeParagraph : IO Bool
|
||||
smokeParagraph = golden "Hello World!" [Paragraph [Text "Hello World!"]]
|
||||
smokeParagraph =
|
||||
golden
|
||||
"Hello World!"
|
||||
[Paragraph [Text "Hello World!"]]
|
||||
|
||||
-- @@test Two Paragraph Smoke
|
||||
smokeTwoParagraph : IO Bool
|
||||
smokeTwoParagraph =
|
||||
golden
|
||||
"Hello World!\n\nHello Alice!"
|
||||
[Paragraph [Text "Hello World!"], Paragraph [Text "Hello Alice!"]]
|
||||
|
|
|
@ -47,7 +47,11 @@ slurp predicate = do
|
|||
if predicate line
|
||||
then do
|
||||
_ <- take
|
||||
slurp predicate
|
||||
Just next <- peek
|
||||
| _ => pure []
|
||||
if predicate next
|
||||
then slurp predicate
|
||||
else pure []
|
||||
else do
|
||||
Just x <- take
|
||||
| _ => pure []
|
||||
|
|
|
@ -30,6 +30,7 @@ renderBlock (Paragraph content) =
|
|||
renderBlocks xs = dMap' (\_, x => renderBlock x) xs
|
||||
|
||||
||| Render a complete html document from a list of block level elements
|
||||
export
|
||||
renderDocument : {types : _} -> DList _ Block types -> Html "html"
|
||||
renderDocument xs =
|
||||
Normal "html" ["lang" =$ "en"] [
|
||||
|
|
|
@ -5,4 +5,5 @@ import Test.Golden.RunnerHelper
|
|||
main : IO ()
|
||||
main = goldenRunner
|
||||
[ "Hedgehog Tests" `atDir` "hedgehog"
|
||||
, "Djot -> HTML Tests" `atDir` "djotToHtml"
|
||||
]
|
||||
|
|
18
test/djotToHtml/001-paragraph/Main.idr
Normal file
18
test/djotToHtml/001-paragraph/Main.idr
Normal file
|
@ -0,0 +1,18 @@
|
|||
module Main
|
||||
|
||||
import SSG.Djot
|
||||
import SSG.HTML
|
||||
|
||||
import System
|
||||
import System.File
|
||||
|
||||
main : IO ()
|
||||
main = do
|
||||
Right contents <- readFile "./test.dj"
|
||||
| Left err => do
|
||||
printLn err
|
||||
exitFailure
|
||||
let (_ ** blocks) = block contents
|
||||
let html = renderDocument blocks
|
||||
let output = render html
|
||||
putStrLn output
|
12
test/djotToHtml/001-paragraph/expected
Normal file
12
test/djotToHtml/001-paragraph/expected
Normal file
|
@ -0,0 +1,12 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html lang=en>
|
||||
<body>
|
||||
<p>Hello World!</p>
|
||||
<p>Hello Alice!</p>
|
||||
<p>A Multi-line
|
||||
Paragraph</p>
|
||||
<p>Two line breaks</p>
|
||||
<p>A multiline paragraph
|
||||
with some indentation</p>
|
||||
</body>
|
||||
</html>
|
5
test/djotToHtml/001-paragraph/pack.toml
Normal file
5
test/djotToHtml/001-paragraph/pack.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
[custom.all.SSG]
|
||||
type = "local"
|
||||
path = "../../.."
|
||||
ipkg = "SSG.ipkg"
|
||||
test = "test/test.ipkg"
|
6
test/djotToHtml/001-paragraph/run
Normal file
6
test/djotToHtml/001-paragraph/run
Normal file
|
@ -0,0 +1,6 @@
|
|||
rm -rf build/
|
||||
|
||||
flock "$1" pack -q install-deps test.ipkg
|
||||
pack -q run test.ipkg
|
||||
|
||||
rm -rf build/
|
12
test/djotToHtml/001-paragraph/test.dj
Normal file
12
test/djotToHtml/001-paragraph/test.dj
Normal file
|
@ -0,0 +1,12 @@
|
|||
Hello World!
|
||||
|
||||
Hello Alice!
|
||||
|
||||
A Multi-line
|
||||
Paragraph
|
||||
|
||||
|
||||
Two line breaks
|
||||
|
||||
A multiline paragraph
|
||||
with some indentation
|
9
test/djotToHtml/001-paragraph/test.ipkg
Normal file
9
test/djotToHtml/001-paragraph/test.ipkg
Normal file
|
@ -0,0 +1,9 @@
|
|||
package a-test
|
||||
|
||||
depends = SSG
|
||||
, hedgehog
|
||||
, eff
|
||||
|
||||
main = Main
|
||||
|
||||
executable = test
|
Loading…
Add table
Reference in a new issue