|
12 | 12 | import org.jsoup.nodes.Element;
|
13 | 13 | import org.junit.Test;
|
14 | 14 | import org.mockito.stubbing.Answer;
|
15 |
| -import org.mozilla.javascript.Context; |
16 |
| -import org.mozilla.javascript.EcmaError; |
17 |
| -import org.mozilla.javascript.tools.shell.Global; |
18 | 15 |
|
19 | 16 | import java.io.File;
|
20 | 17 | import java.io.InputStreamReader;
|
@@ -61,15 +58,38 @@ public void writes_index_html() throws Throwable {
|
61 | 58 | @Test
|
62 | 59 | public void writes_valid_report_js() throws Throwable {
|
63 | 60 | writeReport();
|
64 |
| - URL reportJs = new URL(outputDir, "report.js"); |
65 |
| - Context cx = Context.enter(); |
66 |
| - Global scope = new Global(cx); |
67 |
| - try { |
68 |
| - cx.evaluateReader(scope, new InputStreamReader(reportJs.openStream(), "UTF-8"), reportJs.getFile(), 1, null); |
69 |
| - fail("Should have failed"); |
70 |
| - } catch (EcmaError expected) { |
71 |
| - assertTrue(expected.getMessage().startsWith("ReferenceError: \"document\" is not defined.")); |
72 |
| - } |
| 61 | + String reportJs = FixJava.readReader(new InputStreamReader(new URL(outputDir, "report.js").openStream(), "UTF-8")); |
| 62 | + assertEquals("$(document).ready(function() {var formatter = new CucumberHTML.DOMFormatter($('.cucumber-report'));formatter.uri(\"some\\\\windows\\\\path\\\\some.feature\");\n" + |
| 63 | + "formatter.feature({\n" + |
| 64 | + " \"name\": \"\",\n" + |
| 65 | + " \"description\": \"\",\n" + |
| 66 | + " \"keyword\": \"Feature\"\n" + |
| 67 | + "});\n" + |
| 68 | + "formatter.scenario({\n" + |
| 69 | + " \"name\": \"some cukes\",\n" + |
| 70 | + " \"description\": \"\",\n" + |
| 71 | + " \"keyword\": \"Scenario\"\n" + |
| 72 | + "});\n" + |
| 73 | + "formatter.step({\n" + |
| 74 | + " \"name\": \"first step\",\n" + |
| 75 | + " \"keyword\": \"Given \"\n" + |
| 76 | + "});\n" + |
| 77 | + "formatter.match({\n" + |
| 78 | + " \"location\": \"path/step_definitions.java:3\"\n" + |
| 79 | + "});\n" + |
| 80 | + "formatter.result({\n" + |
| 81 | + " \"status\": \"passed\"\n" + |
| 82 | + "});\n" + |
| 83 | + "formatter.embedding(\"image/png\", \"embedded0.png\");\n" + |
| 84 | + "formatter.after({\n" + |
| 85 | + " \"status\": \"passed\"\n" + |
| 86 | + "});\n" + |
| 87 | + "formatter.embedding(\"text/plain\", \"dodgy stack trace here\");\n" + |
| 88 | + "formatter.after({\n" + |
| 89 | + " \"status\": \"passed\"\n" + |
| 90 | + "});\n" + |
| 91 | + "});", |
| 92 | + reportJs); |
73 | 93 | }
|
74 | 94 |
|
75 | 95 | @Test
|
|
0 commit comments