use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.
the class CleanHtmlDirectiveTest method testApplyForJsSrc.
@Test
public void testApplyForJsSrc() {
CleanHtmlDirective cleanHtml = new CleanHtmlDirective();
JsExpr dataRef = new JsExpr("opt_data.myKey", Integer.MAX_VALUE);
assertThat(cleanHtml.applyForJsSrc(dataRef, ImmutableList.<JsExpr>of()).getText()).isEqualTo("soy.$$cleanHtml(opt_data.myKey)");
}
use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.
the class KeysFunctionTest method testComputeForJsSrc.
@Test
public void testComputeForJsSrc() {
KeysFunction keysFunction = new KeysFunction();
JsExpr expr = new JsExpr("JS_CODE", Integer.MAX_VALUE);
assertThat(keysFunction.computeForJsSrc(ImmutableList.of(expr))).isEqualTo(new JsExpr("soy.$$getMapKeys(JS_CODE)", Integer.MAX_VALUE));
}
use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.
the class LengthFunctionTest method testComputeForJsSrc.
@Test
public void testComputeForJsSrc() {
LengthFunction lengthFunction = new LengthFunction();
JsExpr expr = new JsExpr("JS_CODE", Integer.MAX_VALUE);
assertThat(lengthFunction.computeForJsSrc(ImmutableList.of(expr))).isEqualTo(new JsExpr("JS_CODE.length", Integer.MAX_VALUE));
}
use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.
the class BidiStartEdgeFunctionTest method testComputeForJsSrc.
@Test
public void testComputeForJsSrc() {
assertThat(BIDI_START_EDGE_FUNCTION_FOR_STATIC_LTR.computeForJsSrc(ImmutableList.<JsExpr>of())).isEqualTo(new JsExpr("'left'", Integer.MAX_VALUE));
assertThat(BIDI_START_EDGE_FUNCTION_FOR_STATIC_RTL.computeForJsSrc(ImmutableList.<JsExpr>of())).isEqualTo(new JsExpr("'right'", Integer.MAX_VALUE));
BidiStartEdgeFunction codeSnippet = new BidiStartEdgeFunction(SharedRestrictedTestUtils.BIDI_GLOBAL_DIR_FOR_JS_ISRTL_CODE_SNIPPET_PROVIDER);
assertThat(codeSnippet.computeForJsSrc(ImmutableList.<JsExpr>of())).isEqualTo(new JsExpr("(IS_RTL?-1:1) < 0 ? 'right' : 'left'", Operator.CONDITIONAL.getPrecedence()));
}
use of com.google.template.soy.jssrc.restricted.JsExpr in project closure-templates by google.
the class StrContainsFunctionTest method testComputeForJsSrc_maxPrecedenceArgs.
@Test
public void testComputeForJsSrc_maxPrecedenceArgs() {
StrContainsFunction strContains = new StrContainsFunction();
JsExpr arg0 = new JsExpr("'foobar'", Integer.MAX_VALUE);
JsExpr arg1 = new JsExpr("'bar'", Integer.MAX_VALUE);
assertThat(strContains.computeForJsSrc(ImmutableList.of(arg0, arg1))).isEqualTo(new JsExpr("('foobar').indexOf('bar') != -1", Operator.NOT_EQUAL.getPrecedence()));
}
Aggregations