Skip to content

Commit

Permalink
fix(params): add required to url param, set red for -1
Browse files Browse the repository at this point in the history
  • Loading branch information
CanisHelix committed Mar 4, 2024
1 parent aedd31d commit 4a698af
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
5 changes: 3 additions & 2 deletions services/youtrack/youtrack-helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const description = `
By default this badge looks for projects on [youtrack.jetbrains.com](https://youtrack.jetbrains.com).
To specify a self-hosted instance, use the \`youtrack_url\` query param.
Returns the number of issues for the specified project based on the \`query\` parameter defined.
NOTE: The \`youtrack_url\` query param is required.
`

export { description }
5 changes: 3 additions & 2 deletions services/youtrack/youtrack-issues.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ export default class YoutrackIssues extends YoutrackBase {
}),
queryParam({
name: 'youtrack_url',
example: 'https://youtrack.jetbrains.com',
example: 'https://shields.youtrack.cloud',
required: true,
}),
queryParam({
name: 'query',
Expand All @@ -54,7 +55,7 @@ export default class YoutrackIssues extends YoutrackBase {
return {
label: 'issues',
message: metric(count),
color: count > 0 ? 'yellow' : 'brightgreen',
color: count < 0 ? 'red' : count > 0 ? 'yellow' : 'brightgreen',
}
}

Expand Down
7 changes: 7 additions & 0 deletions services/youtrack/youtrack-issues.tester.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,13 @@ t.create('Issues (DEMO) (Cloud)')
message: isMetricAllowNegative,
})

t.create('Issues (DEMO) (Empty Query) (Cloud)')
.get('/DEMO.json?youtrack_url=https://shields.youtrack.cloud')
.expectBadge({
label: 'issues',
message: isMetricAllowNegative,
})

t.create('Issues (DEMO) (Invalid State) (Cloud Hosted)')
.get('/DEMO.json?https://shields.youtrack.cloud&query=%23ABCDEFG')
.expectBadge({
Expand Down

0 comments on commit 4a698af

Please sign in to comment.