Skip to content

Commit

Permalink
Add a test for whitespaces after ifExpression (playframework#711)
Browse files Browse the repository at this point in the history
  • Loading branch information
yousuketto committed Nov 14, 2023
1 parent 05dbd73 commit 2e0bc84
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions parser/src/test/scala/play/twirl/parser/test/ParserSpec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,25 @@ class ParserSpec extends AnyWordSpec with Matchers with Inside {
val secondCaseBlockBody = secondCaseBlock(1).asInstanceOf[Block]
secondCaseBlockBody.content(1).asInstanceOf[Plain].text mustBe "Not a nice string "
}

"whitespaces after 'else {...}' as plain" in {
val template = parseTemplateString(
"""@if(condition) {ifblock body} else {elseblock body} Some plain text with whitespaces"""
)
val ifExpressions = template.content(0).asInstanceOf[Display].exp.parts
ifExpressions.head must be(Simple("if(condition)"))
val ifBlockBody = ifExpressions(1).asInstanceOf[Block].content(0)
ifBlockBody mustBe Plain("ifblock body")
val elsePart = ifExpressions(2)
elsePart mustBe Simple("else")
val elseBlockBody = ifExpressions(3).asInstanceOf[Block].content(0)
elseBlockBody mustBe Plain("elseblock body")
val afterIfExpressionOfWhitespaces = template.content(1)
afterIfExpressionOfWhitespaces mustBe Plain(" ")
val afterWhitespaces = template.content(2)
afterWhitespaces mustBe Plain("Some plain text with whitespaces")
}

}

"handle local definitions" when {
Expand Down

0 comments on commit 2e0bc84

Please sign in to comment.