Skip to content

Commit

Permalink
Add simple layout builder test
Browse files Browse the repository at this point in the history
  • Loading branch information
iamgio committed Jun 22, 2024
1 parent 7ea5305 commit 6615a13
Showing 1 changed file with 42 additions and 0 deletions.
42 changes: 42 additions & 0 deletions test/src/test/kotlin/eu/iamgio/quarkdown/test/FullPipelineTest.kt
Original file line number Diff line number Diff line change
Expand Up @@ -374,4 +374,46 @@ class FullPipelineTest {
assertEquals(out, it)
}
}

@Test
fun `layout builder`() {
val layoutFunction =
"""
.function {mylayout}
name number:
# Hello, .name!
.number $ \times $ .number is .multiply {.number} by:{.number}
### End
""".trimIndent()

execute(
"$layoutFunction\n.mylayout {world} {3}",
) {
assertEquals(
"<h1>Hello, world!</h1><p>3__QD_INLINE_MATH__$\\times\$__QD_INLINE_MATH__3 is 9</p><h3>End</h3>",
it,
)
}

execute(
layoutFunction +
"""
.foreach {..4}
n:
.mylayout {world} {.n}
""".trimIndent(),
) {
assertEquals(
"<h1>Hello, world!</h1><p>0__QD_INLINE_MATH__$\\times\$__QD_INLINE_MATH__0 is 0</p><h3>End</h3>" +
"<h1>Hello, world!</h1><p>1__QD_INLINE_MATH__$\\times\$__QD_INLINE_MATH__1 is 1</p><h3>End</h3>" +
"<h1>Hello, world!</h1><p>2__QD_INLINE_MATH__$\\times\$__QD_INLINE_MATH__2 is 4</p><h3>End</h3>" +
"<h1>Hello, world!</h1><p>3__QD_INLINE_MATH__$\\times\$__QD_INLINE_MATH__3 is 9</p><h3>End</h3>",
it,
)
}
}
}

0 comments on commit 6615a13

Please sign in to comment.