Skip to content

Commit

Permalink
Merge branch 'master' of github.com:serenity-bdd/serenity-core
Browse files Browse the repository at this point in the history
  • Loading branch information
wakaleo committed Aug 30, 2017
2 parents add3cb1 + 89ef95d commit 19b0706
Show file tree
Hide file tree
Showing 2 changed files with 87 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,44 @@ class WhenFormattingDataForTheHTMLReports extends Specification {
"Érintett _Befogadása_ Alapadatokkal" | "&Eacute;rintett <em>Befogad&aacute;sa</em> Alapadatokkal"
}

@Unroll
def "should render story titles with foreign characters when markdown disabled"() {
expect:
def environmentVariables = new MockEnvironmentVariables()
environmentVariables.setProperty("enable.markdown","not_enabled")
def formatter = new Formatter(issueTracking,environmentVariables)
formatter.htmlCompatibleStoryTitle(foreignWord) == formattedWord
where:
foreignWord | formattedWord
"Érintett Befogadása Alapadatokkal" | "&Eacute;rintett Befogad&aacute;sa Alapadatokkal"
"Érintett _Befogadása_ Alapadatokkal" | "&Eacute;rintett _Befogad&aacute;sa_ Alapadatokkal"
}


@Unroll
def "should render story titles with foreign characters and markdown"() {
expect:
def formatter = new Formatter(issueTracking);
formatter.htmlCompatibleStoryTitle(foreignWord) == formattedWord
where:
foreignWord | formattedWord
"Érintett **Befogadása** Alapadatokkal" | "&Eacute;rintett <strong>Befogad&aacute;sa</strong> Alapadatokkal"
"Érintett _Befogadása_ Alapadatokkal" | "&Eacute;rintett <em>Befogad&aacute;sa</em> Alapadatokkal"
}

@Unroll
def "should render story titles with foreign characters and no markdown"() {
expect:
def environmentVariables = new MockEnvironmentVariables()
environmentVariables.setProperty("enable.markdown","not_enabled")
def formatter = new Formatter(issueTracking,environmentVariables);
formatter.htmlCompatibleStoryTitle(foreignWord) == formattedWord
where:
foreignWord | formattedWord
"Érintett **Befogadása** Alapadatokkal" | "&Eacute;rintett **Befogad&aacute;sa** Alapadatokkal"
"Érintett _Befogadása_ Alapadatokkal" | "&Eacute;rintett _Befogad&aacute;sa_ Alapadatokkal"
}

@Unroll
def "should render simple titles with foreign characters"() {
expect:
Expand All @@ -44,15 +82,29 @@ class WhenFormattingDataForTheHTMLReports extends Specification {
"Érintett Befogadása" | "&Eacute;rintett Befogad&aacute;sa"
"Érintett_Befogadása" | "&Eacute;rintett_Befogad&aacute;sa"
}

@Unroll
def "should render scenario titles with foreign characters and no markdown"() {
expect:
def environmentVariables = new MockEnvironmentVariables()
environmentVariables.setProperty("enable.markdown","not_enabled")
def formatter = new Formatter(issueTracking, environmentVariables);
formatter.htmlCompatibleTestTitle(foreignWord) == formattedWord
where:
foreignWord | formattedWord
"Érintett Befogadása Alapadatokkal" | "&Eacute;rintett Befogad&aacute;sa Alapadatokkal"
"Érintett **Befogadása** Alapadatokkal" | "&Eacute;rintett **Befogad&aacute;sa** Alapadatokkal"
}

@Unroll
def "should render scenario titles with foreign characters"() {
def "should render scenario titles with foreign characters and markdown"() {
expect:
def formatter = new Formatter(issueTracking);
formatter.htmlCompatibleTestTitle(foreignWord) == formattedWord
where:
foreignWord | formattedWord
"Érintett Befogadása Alapadatokkal" | "&Eacute;rintett Befogad&aacute;sa Alapadatokkal"
"Érintett **Befogadása** Alapadatokkal" | "&Eacute;rintett <strong>Befogad&aacute;sa</strong> Alapadatokkal"
}

@Unroll
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,40 @@ public void formatter_should_render_markdown_by_default() {
assertThat(formatted, containsString("a quick <em>brown</em> fox"));
}

@Test
public void formatter_should_not_render_markdown_if_not_configured_for_narrative() {
EnvironmentVariables environmentVariables = new MockEnvironmentVariables();
environmentVariables.setProperty("enable.markdown","story");
Formatter formatter = new Formatter(issueTracking, environmentVariables);
String formatted = formatter.renderDescription("a quick *brown* fox\njumped over a log");
assertThat(formatted, containsString("a quick *brown* fox"));
}

@Test
public void formatter_should_render_markdown_headings_by_default() {
EnvironmentVariables environmentVariables = new MockEnvironmentVariables();
Formatter formatter = new Formatter(issueTracking, environmentVariables);
String formatted = formatter.renderDescription("# Heading");
assertThat(formatted, containsString("<h1>Heading</h1>"));
formatted = formatter.renderDescription("## Sub-heading");
assertThat(formatted, containsString("<h2>Sub-heading</h2>"));
formatted = formatter.renderDescription("### Another deeper heading");
assertThat(formatted, containsString("<h3>Another deeper heading</h3>"));
}

@Test
public void formatter_should_not_render_markdown_headings_if_not_configured() {
EnvironmentVariables environmentVariables = new MockEnvironmentVariables();
environmentVariables.setProperty("enable.markdown","story");
Formatter formatter = new Formatter(issueTracking, environmentVariables);
String formatted = formatter.renderDescription("# Heading");
assertThat(formatted, containsString("# Heading"));
formatted = formatter.renderDescription("## Sub-heading");
assertThat(formatted, containsString("## Sub-heading"));
formatted = formatter.renderDescription("### Another deeper heading");
assertThat(formatted, containsString("### Another deeper heading"));
}

@Test
public void markdown_should_not_affect_escaped_html_characters() {
EnvironmentVariables environmentVariables = new MockEnvironmentVariables();
Expand Down

0 comments on commit 19b0706

Please sign in to comment.