-
-
Notifications
You must be signed in to change notification settings - Fork 225
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
- Loading branch information
1 parent
2d33d8f
commit b55fd35
Showing
3 changed files
with
67 additions
and
3 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
40 changes: 40 additions & 0 deletions
40
server/src/test/java/io/kroki/server/service/DitaaServiceTest.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,40 @@ | ||
package io.kroki.server.service; | ||
|
||
import io.kroki.server.format.FileFormat; | ||
import io.vertx.core.json.JsonObject; | ||
import org.junit.jupiter.api.Test; | ||
|
||
import java.io.ByteArrayInputStream; | ||
import java.io.ByteArrayOutputStream; | ||
import java.io.FileOutputStream; | ||
import java.io.OutputStream; | ||
import java.nio.file.Files; | ||
import java.nio.file.Paths; | ||
|
||
import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; | ||
|
||
public class DitaaServiceTest { | ||
|
||
@Test | ||
public void should_call_ditaa_with_correct_arguments() throws Exception { | ||
String input = "+---------+\n" + | ||
"| cBLU |\n" + | ||
"| |\n" + | ||
"| +----+\n" + | ||
"| |cPNK|\n" + | ||
"| | |\n" + | ||
"+----+----+"; | ||
try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(input.getBytes()); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) { | ||
Ditaa.convert(FileFormat.SVG, new JsonObject(), byteArrayInputStream, byteArrayOutputStream); | ||
// shadows are enabled by default | ||
assertThat(byteArrayOutputStream.toString()).contains("filter=\"url(#shadowBlur)\""); | ||
} | ||
try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(input.getBytes()); ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream()) { | ||
JsonObject options = new JsonObject(); | ||
options.put("no-shadows", ""); | ||
Ditaa.convert(FileFormat.SVG, options, byteArrayInputStream, byteArrayOutputStream); | ||
// disable shadows by setting the no-shadows option | ||
assertThat(byteArrayOutputStream.toString()).doesNotContain("filter=\"url(#shadowBlur)\""); | ||
} | ||
} | ||
} |