|
15 | 15 | */
|
16 | 16 | package net.codestory.http.templating;
|
17 | 17 |
|
18 |
| -import static java.util.Arrays.*; |
19 |
| -import static org.assertj.core.api.Assertions.*; |
20 |
| -import static org.mockito.Mockito.*; |
21 |
| - |
22 |
| -import java.io.*; |
23 |
| -import java.nio.file.*; |
24 |
| -import java.util.*; |
25 |
| - |
26 |
| -import net.codestory.http.compilers.*; |
| 18 | +import com.github.jknack.handlebars.HandlebarsException; |
| 19 | +import net.codestory.http.compilers.CompilerFacade; |
27 | 20 | import net.codestory.http.io.Resources;
|
28 |
| -import net.codestory.http.markdown.*; |
29 |
| -import net.codestory.http.misc.*; |
30 |
| -import net.codestory.http.templating.helpers.*; |
| 21 | +import net.codestory.http.markdown.MarkdownCompiler; |
| 22 | +import net.codestory.http.misc.Env; |
| 23 | +import net.codestory.http.templating.helpers.GoogleAnalyticsHelper; |
| 24 | +import org.junit.Test; |
31 | 25 |
|
32 |
| -import org.junit.*; |
| 26 | +import java.io.IOException; |
| 27 | +import java.nio.file.Paths; |
| 28 | +import java.util.Map; |
| 29 | +import java.util.TreeMap; |
33 | 30 |
|
34 |
| -import com.github.jknack.handlebars.*; |
| 31 | +import static java.util.Arrays.asList; |
| 32 | +import static org.assertj.core.api.Assertions.assertThat; |
| 33 | +import static org.mockito.Mockito.mock; |
| 34 | +import static org.mockito.Mockito.when; |
35 | 35 |
|
36 | 36 | public class HandlebarsCompilerTest {
|
37 | 37 | static Env env = Env.prod();
|
@@ -78,13 +78,6 @@ public void find_partial() throws IOException {
|
78 | 78 | assertThat(result).isEqualTo("Hello Bob");
|
79 | 79 | }
|
80 | 80 |
|
81 |
| - @Test |
82 |
| - public void markdown_partial() throws IOException { |
83 |
| - String result = compile("[[>map city]]", map("city", "Paris")); |
84 |
| - |
85 |
| - assertThat(result).isEqualTo("<p><a href=\"https://maps.google.com/maps?q=+Paris\"> Paris</a></p>\n"); |
86 |
| - } |
87 |
| - |
88 | 81 | @Test(expected = HandlebarsException.class)
|
89 | 82 | public void unknown_partial() throws IOException {
|
90 | 83 | compile("[[>unknown]]", map("", ""));
|
@@ -135,34 +128,15 @@ public void each_reverse() throws IOException {
|
135 | 128 | @Test
|
136 | 129 | public void values_by_key() throws IOException {
|
137 | 130 | Map<String, Object> variables = new TreeMap<>();
|
138 |
| - variables.put("letters", asList("A", "B")); |
139 | 131 | variables.put("descriptions", new TreeMap<String, Object>() {{
|
140 | 132 | put("A", "Letter A");
|
141 | 133 | put("B", "Letter B");
|
142 | 134 | put("C", "Letter C");
|
143 | 135 | }});
|
144 | 136 |
|
145 |
| - String result = compile("[[#each_value descriptions letters]][[@key]]=[[.]][[/each_value]]", variables); |
146 |
| - |
147 |
| - assertThat(result).isEqualTo("A=Letter AB=Letter B"); |
148 |
| - } |
149 |
| - |
150 |
| - @Test |
151 |
| - public void values_by_hash_key() throws IOException { |
152 |
| - Map<String, Object> variables = new TreeMap<>(); |
153 |
| - variables.put("letters", new TreeMap<String, Object>() {{ |
154 |
| - put("A", map("id", "idA")); |
155 |
| - put("B", map("id", "idB")); |
156 |
| - }}); |
157 |
| - variables.put("descriptions", new TreeMap<String, Object>() {{ |
158 |
| - put("A", "Description A"); |
159 |
| - put("B", "Description B"); |
160 |
| - put("C", "Description C"); |
161 |
| - }}); |
162 |
| - |
163 |
| - String result = compile("[[#each_value descriptions letters]][[@value.id]]=[[.]][[/each_value]]", variables); |
| 137 | + String result = compile("[[#each descriptions]][[@key]]=[[.]][[/each]]", variables); |
164 | 138 |
|
165 |
| - assertThat(result).isEqualTo("idA=Description AidB=Description B"); |
| 139 | + assertThat(result).isEqualTo("A=Letter AB=Letter BC=Letter C"); |
166 | 140 | }
|
167 | 141 |
|
168 | 142 | @Test
|
|
0 commit comments