-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Adding Guice] making a lot of Desktop HTML tags tests pass
- Loading branch information
Showing
23 changed files
with
182 additions
and
167 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
src/test/java/br/com/caelum/tubaina/parser/html/desktop/AbstractTagTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package br.com.caelum.tubaina.parser.html.desktop; | ||
|
||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
import br.com.caelum.tubaina.Chunk; | ||
import br.com.caelum.tubaina.chunk.MockedChunk; | ||
|
||
public class AbstractTagTest { | ||
protected String getContent(Chunk chunk) { | ||
new HtmlModule().inject(chunk); | ||
return chunk.asString(); | ||
} | ||
|
||
protected List<Chunk> text(String text) { | ||
return Arrays.<Chunk>asList(new MockedChunk(text)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 17 additions & 10 deletions
27
src/test/java/br/com/caelum/tubaina/parser/html/desktop/CodeTagTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,30 @@ | ||
package br.com.caelum.tubaina.parser.html.desktop; | ||
|
||
import static org.mockito.Mockito.mock; | ||
import static org.mockito.Mockito.verify; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Test; | ||
|
||
import br.com.caelum.tubaina.parser.html.HtmlAndKindleCodeTag; | ||
import br.com.caelum.tubaina.chunk.CodeChunk; | ||
|
||
public class CodeTagTest { | ||
public class CodeTagTest extends AbstractTagTest { | ||
|
||
@Test | ||
public void shouldCallHtmlCodeTag() { | ||
String code = "public static void main(String[] args) {\n" + | ||
" String name = \"Gabriel\";\n" + | ||
" System.out.println(\"Hello, \" + name);\n" + | ||
"}"; | ||
HtmlAndKindleCodeTag htmlCodeTag = mock(HtmlAndKindleCodeTag.class); | ||
CodeTag codeTag = new CodeTag(htmlCodeTag); | ||
codeTag.parse(chunk); | ||
verify(htmlCodeTag).parse(chunk); | ||
} | ||
CodeChunk chunk = new CodeChunk(code, ""); | ||
String result = getContent(chunk); | ||
Assert.assertEquals("<pre ><div class=\"highlight\">" + | ||
"<pre><span class=\"lineno\">1</span> " + | ||
"public static void main(String[] args) {" + | ||
"\n<span class=\"lineno\">2</span> " + | ||
" String name = "Gabriel";" + | ||
"\n<span class=\"lineno\">3</span> " + | ||
" System.out.println("Hello, " + name);" + | ||
"\n<span class=\"lineno\">4</span>" + | ||
" }" + | ||
"\n</pre>" + | ||
"</div></pre>", result); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 7 additions & 12 deletions
19
src/test/java/br/com/caelum/tubaina/parser/html/desktop/ImageTagTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,16 @@ | ||
package br.com.caelum.tubaina.parser.html.desktop; | ||
|
||
import junit.framework.Assert; | ||
|
||
import org.junit.Test; | ||
|
||
import br.com.caelum.tubaina.TubainaException; | ||
import br.com.caelum.tubaina.chunk.ImageChunk; | ||
|
||
public class ImageTagTest { | ||
public class ImageTagTest extends AbstractTagTest { | ||
|
||
@Test | ||
public void shouldThrowExpectionWhenTagContainsLabel() { | ||
ImageTag tag = new ImageTag(); | ||
try { | ||
tag.parse(chunk); | ||
Assert.fail("should throw excpetion"); | ||
} catch (TubainaException e) { | ||
} | ||
} | ||
@Test(expected=TubainaException.class) | ||
public void shouldThrowExceptionWhenTagContainsLabel() { | ||
ImageChunk chunk = new ImageChunk("image.png", "label=someLabel", 100, 1); | ||
getContent(chunk); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.