Skip to content

Commit

Permalink
Show dashes (-) instead of 0 in the table (#443)
Browse files Browse the repository at this point in the history
## Summary

### Motivation

Show dashes (-) instead of 0 in the table

## Testing

### Test Types

- [x] Unit tests
- [ ] Manual tests
  • Loading branch information
GordonBeeming committed Dec 12, 2023
1 parent ccdcdf4 commit 672351a
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

7 changes: 6 additions & 1 deletion src/task/src/pullRequests/pullRequestComments.ts
Expand Up @@ -202,6 +202,11 @@ export default class PullRequestComments {
surround = '**'
}

return `${surround}${title}${surround}|${surround}${metric.toLocaleString()}${surround}\n`
let metricString = metric.toLocaleString()
if (metricString === '0') {
metricString = '-'
}

return `${surround}${title}${surround}|${surround}${metricString}${surround}\n`
}
}
10 changes: 5 additions & 5 deletions src/task/tests/pullRequests/pullRequestComments.spec.ts
Expand Up @@ -359,11 +359,11 @@ describe('pullRequestComments.ts', (): void => {
'✔ **Thanks for adding tests.**\n' +
'||Lines\n' +
'-|-:\n' +
`Product Code|${code[0].toLocaleString()}\n` +
`Test Code|${code[1].toLocaleString()}\n` +
`**Subtotal**|**${code[2].toLocaleString()}**\n` +
`Ignored Code|${code[3].toLocaleString()}\n` +
`**Total**|**${code[4].toLocaleString()}**\n` +
`Product Code|${code[0].toLocaleString() === '0' ? '-' : code[0].toLocaleString()}\n` +
`Test Code|${code[1].toLocaleString() === '0' ? '-' : code[1].toLocaleString()}\n` +
`**Subtotal**|**${code[2].toLocaleString() === '0' ? '-' : code[2].toLocaleString()}**\n` +
`Ignored Code|${code[3].toLocaleString() === '0' ? '-' : code[3].toLocaleString()}\n` +
`**Total**|**${code[4].toLocaleString() === '0' ? '-' : code[4].toLocaleString()}**\n` +
'\n' +
'[Metrics computed by PR Metrics. Add it to your Azure DevOps and GitHub PRs!](https://aka.ms/PRMetrics/Comment)')
verify(logger.logDebug('* PullRequestComments.getMetricsComment()')).once()
Expand Down

0 comments on commit 672351a

Please sign in to comment.