Skip to content

Commit

Permalink
use metric() for [discord] and [revolt] badges (#10406)
Browse files Browse the repository at this point in the history
  • Loading branch information
chris48s authored Jul 26, 2024
1 parent 615ecaa commit be542e1
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 7 deletions.
3 changes: 2 additions & 1 deletion services/discord/discord.service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Joi from 'joi'
import { nonNegativeInteger } from '../validators.js'
import { metric } from '../text-formatters.js'
import { BaseJsonService, pathParams } from '../index.js'

const schema = Joi.object({
Expand Down Expand Up @@ -53,7 +54,7 @@ export default class Discord extends BaseJsonService {

static render({ members }) {
return {
message: `${members} online`,
message: `${metric(members)} online`,
color: 'brightgreen',
}
}
Expand Down
5 changes: 3 additions & 2 deletions services/discord/discord.tester.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import Joi from 'joi'
import { createServiceTester } from '../tester.js'
import { isMetricWithPattern } from '../test-validators.js'

export const t = await createServiceTester()

t.create('gets status for Reactiflux')
.get('/102860784329052160.json')
.expectBadge({
label: 'chat',
message: Joi.string().regex(/^[0-9]+ online$/),
message: isMetricWithPattern(/ online/),
color: 'brightgreen',
})

Expand Down
3 changes: 2 additions & 1 deletion services/revolt/revolt.service.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import Joi from 'joi'
import { BaseJsonService, pathParam, queryParam } from '../index.js'
import { metric } from '../text-formatters.js'
import { nonNegativeInteger, optionalUrl } from '../validators.js'

const schema = Joi.object({
Expand Down Expand Up @@ -52,7 +53,7 @@ export default class RevoltServerInvite extends BaseJsonService {

static render({ memberCount }) {
return {
message: `${memberCount} members`,
message: `${metric(memberCount)} members`,
color: 'brightgreen',
}
}
Expand Down
6 changes: 3 additions & 3 deletions services/revolt/revolt.tester.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import Joi from 'joi'
import { createServiceTester } from '../tester.js'
import { isMetricWithPattern } from '../test-validators.js'

export const t = await createServiceTester()

t.create('get status of #revolt')
.get('/01F7ZSBSFHQ8TA81725KQCSDDP.json')
.expectBadge({
label: 'chat',
message: Joi.string().regex(/^[0-9]+ members$/),
message: isMetricWithPattern(/ members/),
color: 'brightgreen',
})

Expand All @@ -17,7 +17,7 @@ t.create('custom api url')
)
.expectBadge({
label: 'chat',
message: Joi.string().regex(/^[0-9]+ members$/),
message: isMetricWithPattern(/ members/),
color: 'brightgreen',
})

Expand Down

0 comments on commit be542e1

Please sign in to comment.