Skip to content

Commit

Permalink
Merge pull request #116 from mxstbr/fix-fails
Browse files Browse the repository at this point in the history
Don't output table if no violations are specified
  • Loading branch information
orta committed Jan 29, 2017
2 parents 7cdb784 + f156775 commit 5c10c75
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 6 deletions.
8 changes: 5 additions & 3 deletions changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@

// Add your own contribution below

* Builds which only use markdown now only show the markdown, and no violations table is shown - mxstbr

### 0.10.0

* Adds support for running Danger against a PR locally - orta

The workflow is that you find a PR that exhibits the behavior you'd like Danger to run against,
The workflow is that you find a PR that exhibits the behavior you'd like Danger to run against,
then edit the local `Dangerfile.js` and run `yarn run danger pr https://github.com/facebook/jest/pull/2629`.

This will post the results to your console, instead of on the PR itself.
Expand All @@ -19,8 +21,8 @@ This will post the results to your console, instead of on the PR itself.

* Adds support for `git.commits` and `github.commits` - orta

Why two? Well github.commits contains a bunch of github specific metadata ( e.g. GitHub user creds,
commit comment counts. ) Chances are, you're always going to use `git.commits` however if you
Why two? Well github.commits contains a bunch of github specific metadata ( e.g. GitHub user creds,
commit comment counts. ) Chances are, you're always going to use `git.commits` however if you
want more rich data, the GitHub one is available too. Here's an example:

```js
Expand Down
9 changes: 8 additions & 1 deletion source/runner/_tests/fixtures/ExampleDangerResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export const emptyResults: DangerResults = {
markdowns: []
}

export const failsResultsWithoutMessages: DangerResults = {
fails: [{}, {}],
warnings: [],
messages: [],
markdowns: []
}

export const warnResults: DangerResults = {
fails: [],
warnings: [{ message: "Warning message" }],
Expand All @@ -26,4 +33,4 @@ export const summaryResults: DangerResults = {
warnings: [{ message: "Warning message Warning message" }],
messages: [{ message: "message" }],
markdowns: ["markdown"],
}
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { emptyResults, warnResults, failsResults, summaryResults } from "../../_tests/fixtures/ExampleDangerResults"
import { emptyResults, failsResultsWithoutMessages, warnResults, failsResults, summaryResults } from "../../_tests/fixtures/ExampleDangerResults"
import { template as githubResultsTemplate } from "../../templates/github-issue-template"

describe("generating messages", () => {
Expand All @@ -9,6 +9,13 @@ describe("generating messages", () => {
expect(issues).not.toContain("Messages")
})

it("shows no tables for results without messages", () => {
const issues = githubResultsTemplate(failsResultsWithoutMessages)
expect(issues).not.toContain("Fails")
expect(issues).not.toContain("Warnings")
expect(issues).not.toContain("Messages")
})

it("Shows the failing messages in a table", () => {
const issues = githubResultsTemplate(failsResults)
expect(issues).toContain("Fails")
Expand Down
2 changes: 1 addition & 1 deletion source/runner/templates/github-issue-template.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import * as v from "voca"
* @returns {string} HTML
*/
function table(name: string, emoji: string, violations: Array<Violation>): string {
if (violations.length === 0) { return "" }
if (violations.length === 0 || violations.every(violation => !violation.message)) { return "" }
return `
<table>
<thead>
Expand Down

0 comments on commit 5c10c75

Please sign in to comment.