Skip to content
This repository has been archived by the owner on Jun 2, 2020. It is now read-only.

Commit

Permalink
test: add tests for react 15+
Browse files Browse the repository at this point in the history
  • Loading branch information
KnisterPeter committed Jan 25, 2017
1 parent 61dfa9b commit 0b20336
Show file tree
Hide file tree
Showing 1,475 changed files with 126,858 additions and 0 deletions.
25 changes: 25 additions & 0 deletions src/test/java/de/matrixweb/jreact/JReactClasspathTest.java
Expand Up @@ -37,6 +37,12 @@ private JReact setupReact014() {
return react;
}

private JReact setupReact015() {
final JReact react = new JReact();
react.addRequirePath("./src/test/resources/react-0.15");
return react;
}

@Test
public void testRenderWithReact011() throws IOException {
dynamicMarkup(setupReact011());
Expand Down Expand Up @@ -106,6 +112,16 @@ public void testStaticRenderWithReact014() throws IOException {
staticMarkup(setupReact014());
}

@Test
public void testDynamicRenderWithReact015() throws IOException {
dynamicMarkup15(setupReact015());
}

@Test
public void testStaticRenderWithReact015() throws IOException {
staticMarkup(setupReact015());
}

private void dynamicMarkup(final JReact react) throws IOException {
final Map<String, Object> props = new HashMap<>();
props.put("text", "Hello World!");
Expand All @@ -115,6 +131,15 @@ private void dynamicMarkup(final JReact react) throws IOException {
assertThat(result, endsWith("\">Hello World!</div>"));
}

private void dynamicMarkup15(final JReact react) throws IOException {
final Map<String, Object> props = new HashMap<>();
props.put("text", "Hello World!");
final String result = react.renderToString("./test.js", props);

assertThat(result, startsWith("<div data-reactroot=\""));
assertThat(result, endsWith("\">Hello World!</div>"));
}

private void staticMarkup(final JReact react) throws IOException {
final Map<String, Object> props = new HashMap<>();
props.put("text", "Hello World!");
Expand Down
25 changes: 25 additions & 0 deletions src/test/java/de/matrixweb/jreact/JReactTest.java
Expand Up @@ -37,6 +37,12 @@ private JReact setupReact014() {
return react;
}

private JReact setupReact015() {
final JReact react = new JReact();
react.addRequirePath("./src/test/resources/react-0.15");
return react;
}

@Test
public void testRenderWithReact011() throws IOException {
dynamicMarkup(setupReact011());
Expand Down Expand Up @@ -105,6 +111,16 @@ public void testStaticRenderWithReact014() throws IOException {
staticMarkup(setupReact014());
}

@Test
public void testDynamicRenderWithReact015() throws IOException {
dynamicMarkup15(setupReact015());
}

@Test
public void testStaticRenderWithReact015() throws IOException {
staticMarkup(setupReact015());
}

private void dynamicMarkup(final JReact react) throws IOException {
final Map<String, Object> props = new HashMap<>();
props.put("text", "Hello World!");
Expand All @@ -114,6 +130,15 @@ private void dynamicMarkup(final JReact react) throws IOException {
assertThat(result, endsWith("\">Hello World!</div>"));
}

private void dynamicMarkup15(final JReact react) throws IOException {
final Map<String, Object> props = new HashMap<>();
props.put("text", "Hello World!");
final String result = react.renderToString("./test.js", props);

assertThat(result, startsWith("<div data-reactroot=\""));
assertThat(result, endsWith("\">Hello World!</div>"));
}

private void staticMarkup(final JReact react) throws IOException {
final Map<String, Object> props = new HashMap<>();
props.put("text", "Hello World!");
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

64 changes: 64 additions & 0 deletions src/test/resources/react-0.15/node_modules/asap/CHANGES.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

21 changes: 21 additions & 0 deletions src/test/resources/react-0.15/node_modules/asap/LICENSE.md

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0b20336

Please sign in to comment.