Commits

David Black [Atlassian] committed 17ec72b

SOY-33: Add a test for a 'missing' getText key being escaped in the result.
Where a getText key cannot be found getText returns value of the key given to it and so we escape it.

Signed-off-by: David Black <dblack@atlassian.com>

  • Participants
  • Parent commits 4f8cd3c
  • Branches do_not_convert_existing_soy_data, issue/SOY-33 1
    1. issue/SOY-46

Comments (0)

Files changed (1)

File soy-template-plugin/src/test/java/com/atlassian/soy/impl/functions/GetTextAsHtmlFunctionTest.java

 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertTrue;
 import static org.mockito.Matchers.anyString;
+import static org.mockito.Matchers.eq;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.verify;
 
         assertEquals(((SanitizedContent) result).getContentKind(),
             SanitizedContent.ContentKind.HTML);
     }
+
+    @Test
+    public void TestForTofuWithMissingKey() throws Exception
+    {
+        final String getTextKey = "<ma.key";
+        doReturn(getTextKey).when(i18nResolver).getText(eq(getTextKey),
+            Matchers.<Serializable>anyVararg());
+        SoyData result = function.computeForTofu(Arrays.<SoyData>asList(
+            StringData.forValue(getTextKey), StringData.forValue("")));
+        assertEquals(Sanitizers.escapeHtml(getTextKey), result.toString());
+    }
+
 }