package net.symphonious.commonjs;

import org.junit.Test;

import static org.hamcrest.CoreMatchers.is;
import static org.junit.Assert.assertThat;

public class CommonJsCompilerTest
{
    private static final String SIMPLE_JAVASCRIPT = "console.log('Hello World!');";

    private final InMemoryModuleLoader moduleLoader = new InMemoryModuleLoader();
    private final CommonJsCompiler compiler = new CommonJsCompiler(moduleLoader);

    @Test
    public void shouldCompileFileWithNoDependencies() throws Exception
    {
        moduleLoader.addModule("main", SIMPLE_JAVASCRIPT);

        assertThat(compiler.compile("main"), is(SIMPLE_JAVASCRIPT));
    }
}
@@ -52,16 +52,129 @@
 .Test;%0A%0A
+import javax.script.ScriptEngine;%0Aimport javax.script.ScriptEngineManager;%0Aimport javax.script.ScriptException;%0A%0A
 import s
@@ -346,35 +346,22 @@
  = %22
-console.log(
 'Hello 
-W
+w
 orld!'
-)
 ;%22;%0A
@@ -687,19 +687,35 @@
   assert
-Tha
+ScriptProducesOutpu
 t(compil
@@ -738,28 +738,411 @@
 %22), 
-is(SIMPLE_JAVASCRIPT
+%22Hello world!%22);%0A    %7D%0A%0A    private void assertScriptProducesOutput(final String script, final String expectedOutput) throws ScriptException%0A    %7B%0A        final ScriptEngineManager scriptEngineManager = new ScriptEngineManager();%0A        final ScriptEngine javascriptEngine = scriptEngineManager.getEngineByMimeType(%22text/javascript%22);%0A        assertThat(javascriptEngine.eval(script), is(expectedOutput
 ));%0A

Move test to asserting the result of the script instead of doing a simple text comparison.