Skip to content

Commit

Permalink
Fix a problem with a big comment for the same file/line
Browse files Browse the repository at this point in the history
  • Loading branch information
sunshinejr committed Apr 1, 2018
1 parent 40ebf98 commit 672d573
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 6 deletions.
19 changes: 19 additions & 0 deletions source/runner/_tests/fixtures/ExampleDangerResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,25 @@ export const inlineRegularResults: DangerResults = {
markdowns: [],
}

export const inlineRegularResultsForTheSameLine: DangerResults = {
messages: [
{ message: "Test message", file: "File.swift", line: 10 },
{ message: "Warning message", file: "File.swift", line: 10 },
],
warnings: [
{ message: "Test message", file: "File.swift", line: 10 },
{ message: "Warning message", file: "File.swift", line: 10 },
],
fails: [
{ message: "Test message", file: "File.swift", line: 10 },
{ message: "Warning message", file: "File.swift", line: 10 },
],
markdowns: [
{ message: "Test message", file: "File.swift", line: 10 },
{ message: "Warning message", file: "File.swift", line: 10 },
],
}

export const failsResults: DangerResults = {
fails: [{ message: "Failing message" }],
warnings: [],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,28 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`generating inline messages Shows correct message for multiple inline violations for the same file and line 1`] = `
"
<!--
2 failure: Test message, Warning message
2 warning: Test message, Warning message
2 messages
2 markdown notices
DangerID: danger-id-blankID;
File: File.swift;
Line: 10;
-->
- :no_entry_sign: Test message
- :no_entry_sign: Warning message
- :warning: Test message
- :warning: Warning message
- :book: Test message
- :book: Warning message
Test message
Warning message
"
`;

exports[`generating inline messages Shows correct messages for inline/regular violations 1`] = `
"
<!--
Expand Down
7 changes: 7 additions & 0 deletions source/runner/templates/_tests/_githubIssueTemplates.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
messagesResults,
markdownResults,
inlineRegularResults,
inlineRegularResultsForTheSameLine,
} from "../../_tests/fixtures/ExampleDangerResults"
import {
template as githubResultsTemplate,
Expand Down Expand Up @@ -124,4 +125,10 @@ describe("generating inline messages", () => {

expect(issues).toMatchSnapshot()
})

it("Shows correct message for multiple inline violations for the same file and line", () => {
const issues = githubResultsInlineTemplate("blankID", inlineRegularResultsForTheSameLine, "File.swift", 10)

expect(issues).toMatchSnapshot()
})
})
6 changes: 3 additions & 3 deletions source/runner/templates/bitbucketServerTemplate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ export function inlineTemplate(results: DangerResults): string {
}

return `
${results.fails.map(printViolation("no_entry_sign"))}
${results.warnings.map(printViolation("warning"))}
${results.messages.map(printViolation("book"))}
${results.fails.map(printViolation("no_entry_sign")).join("\n")}
${results.warnings.map(printViolation("warning")).join("\n")}
${results.messages.map(printViolation("book")).join("\n")}
${results.markdowns.map(v => v.message).join("\n\n")}
`
}