@@ -76,9 +76,15 @@ class EmailServiceTest {
7676 .let { it.getBodyPart(0 ).content as MimeMultipart }
7777 .let { it.getBodyPart(0 ).content as String }
7878 .assert
79- .contains(" Value of `testVar` : <span>test!!</span>" )
79+ .contains(" Testing ICU strings -- test!!" )
80+ .contains(" Value of `testVar`: <span>test!!</span>" )
8081 .contains(" <span>Was `testVar` equal to "meow" : </span><span>no</span>" )
81- .contains(" Powered by" )
82+ // Makes sure tag handling works as expected
83+ .contains(
84+ " Powered by <a href=\" https://tolgee.io\" style=\" color:inherit;text-decoration-line:underline\" " +
85+ " target=\" _blank\" >Tolgee</a>" ,
86+ )
87+ // Might be a bit brittle but does the trick for now.
8288 .doesNotContain(" th:" )
8389 .doesNotContain(" data-th" )
8490 }
@@ -95,10 +101,31 @@ class EmailServiceTest {
95101 .let { it.getBodyPart(0 ).content as MimeMultipart }
96102 .let { it.getBodyPart(0 ).content as String }
97103 .assert
98- .contains(" Value of `testVar` : <span>meow</span>" )
104+ .contains(" Testing ICU strings -- meow" )
105+ .contains(" Value of `testVar`: <span>meow</span>" )
99106 .contains(" <span>Was `testVar` equal to "meow" : </span><span>yes</span>" )
100107 }
101108
109+ @Test
110+ fun `it correctly processes foreach blocks` () {
111+ // FWIW this is very close to just testing Thymeleaf itself, but it serves as a sanity check for the template itself
112+ emailService.sendEmailTemplate(
" [email protected] " ,
" zz-test-email" ,
Locale .
ENGLISH ,
TEST_PROPERTIES_MEOW )
113+ verify(mailSender).send(emailCaptor.capture())
114+
115+ val email = emailCaptor.value
116+ email.content
117+ .let { it as MimeMultipart }
118+ .let { it.getBodyPart(0 ).content as MimeMultipart }
119+ .let { it.getBodyPart(0 ).content as String }
120+ .assert
121+ .contains(" Plain test: <span>Name #1</span>" )
122+ .contains(" <span>ICU test: Name #1</span>" )
123+ .contains(" Plain test: <span>Name #2</span>" )
124+ .contains(" <span>ICU test: Name #2</span>" )
125+ .contains(" Plain test: <span>Name #3</span>" )
126+ .contains(" <span>ICU test: Name #3</span>" )
127+ }
128+
102129 companion object {
103130 private val TEST_PROPERTIES =
104131 mapOf (
0 commit comments