/** Check the syntax */ @Test public void testJsScopeSyntax() { String expectedJavascript = "function(params) {\n\talert('test');\n}"; JsScopePositionEvent scopeUiEvent = new JsScopePositionEvent() { private static final long serialVersionUID = 1L; @Override protected void execute(JsScopeContext scopeContext) { scopeContext.append("alert('test');"); } }; String generatedJavascript = scopeUiEvent.render().toString(); log.info(expectedJavascript); log.info(generatedJavascript); assertEquals(generatedJavascript, expectedJavascript); // Second generation generatedJavascript = scopeUiEvent.render().toString(); log.info(expectedJavascript); log.info(generatedJavascript); assertEquals(generatedJavascript, expectedJavascript); }
/** Check the quickScope function */ @Test public void testQuickScope() { String expectedJavascript = "function(params) {\n\talert('test');\n}"; JsScopePositionEvent quickScope = JsScopePositionEvent.quickScope("alert('test');"); String generatedJavascript = quickScope.render().toString(); log.info(expectedJavascript); log.info(generatedJavascript); assertEquals(generatedJavascript, expectedJavascript); // Second generation generatedJavascript = quickScope.render().toString(); log.info(expectedJavascript); log.info(generatedJavascript); assertEquals(generatedJavascript, expectedJavascript); }