-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add tests for HtmlGanttDiagramReporter
- Loading branch information
Showing
3 changed files
with
51 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -10,6 +10,7 @@ data class HtmlConfig(override val enabled: Boolean, override val outputLocation | |
private const val DEFAULT_MERMAID_SCRIPT_SRC = | ||
"https://cdn.jsdelivr.net/npm/[email protected]/dist/mermaid.min.js" | ||
|
||
@JvmStatic | ||
fun getSrcDefault(): String = DEFAULT_MERMAID_SCRIPT_SRC | ||
} | ||
|
||
|
49 changes: 49 additions & 0 deletions
49
...io/github/platan/tests_execution_chart/reporters/html/HtmlGanttDiagramReporterTest.groovy
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,49 @@ | ||
package io.github.platan.tests_execution_chart.reporters.html | ||
|
||
import io.github.platan.tests_execution_chart.report.TestExecutionScheduleReportBuilder | ||
import spock.lang.Specification | ||
import spock.lang.Subject | ||
import spock.lang.TempDir | ||
|
||
class HtmlGanttDiagramReporterTest extends Specification { | ||
|
||
@Subject | ||
def htmlGanttDiagramReporter = new HtmlGanttDiagramReporter() | ||
def configOutputLocation = "my-output-location" | ||
|
||
def setup() { | ||
htmlGanttDiagramReporter.setLogger { println(it) } | ||
} | ||
|
||
@TempDir | ||
File baseDir | ||
|
||
def "should embed script file"() { | ||
given: | ||
def script = new HtmlConfig.Script(HtmlConfig.Script.getSrcDefault(), true, new HtmlConfig.Script.Options(10_000)) | ||
htmlGanttDiagramReporter.setConfiguration(new HtmlConfig(true, configOutputLocation, script)) | ||
def report = new TestExecutionScheduleReportBuilder().build() | ||
|
||
when: | ||
htmlGanttDiagramReporter.report(report, baseDir, 'my-task') | ||
|
||
then: | ||
def reportContent = new File(baseDir, "$configOutputLocation/my-task.html").text | ||
reportContent.contains '<script src="mermaid.min.js"></script>' | ||
} | ||
|
||
def "should not embed script file"() { | ||
given: | ||
def scriptSource = HtmlConfig.Script.getSrcDefault() | ||
def script = new HtmlConfig.Script(scriptSource, false, new HtmlConfig.Script.Options(10_000)) | ||
htmlGanttDiagramReporter.setConfiguration(new HtmlConfig(true, configOutputLocation, script)) | ||
def report = new TestExecutionScheduleReportBuilder().build() | ||
|
||
when: | ||
htmlGanttDiagramReporter.report(report, baseDir, 'my-task') | ||
|
||
then: | ||
def reportContent = new File(baseDir, "$configOutputLocation/my-task.html").text | ||
reportContent.contains """<script src="$scriptSource"></script>""" | ||
} | ||
} |
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