From be542e17af8d64db2479ca09c3dc421aaf7c6cd7 Mon Sep 17 00:00:00 2001 From: chris48s Date: Fri, 26 Jul 2024 10:17:59 +0100 Subject: [PATCH] use metric() for [discord] and [revolt] badges (#10406) --- services/discord/discord.service.js | 3 ++- services/discord/discord.tester.js | 5 +++-- services/revolt/revolt.service.js | 3 ++- services/revolt/revolt.tester.js | 6 +++--- 4 files changed, 10 insertions(+), 7 deletions(-) diff --git a/services/discord/discord.service.js b/services/discord/discord.service.js index eecb9b653dd2e..fa5acd49750ef 100644 --- a/services/discord/discord.service.js +++ b/services/discord/discord.service.js @@ -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({ @@ -53,7 +54,7 @@ export default class Discord extends BaseJsonService { static render({ members }) { return { - message: `${members} online`, + message: `${metric(members)} online`, color: 'brightgreen', } } diff --git a/services/discord/discord.tester.js b/services/discord/discord.tester.js index 4d027b24b7823..d6466fd519c91 100644 --- a/services/discord/discord.tester.js +++ b/services/discord/discord.tester.js @@ -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', }) diff --git a/services/revolt/revolt.service.js b/services/revolt/revolt.service.js index e43763e5b722f..328a5f28d1269 100644 --- a/services/revolt/revolt.service.js +++ b/services/revolt/revolt.service.js @@ -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({ @@ -52,7 +53,7 @@ export default class RevoltServerInvite extends BaseJsonService { static render({ memberCount }) { return { - message: `${memberCount} members`, + message: `${metric(memberCount)} members`, color: 'brightgreen', } } diff --git a/services/revolt/revolt.tester.js b/services/revolt/revolt.tester.js index aa7a046e957c2..3b2eb963eb222 100644 --- a/services/revolt/revolt.tester.js +++ b/services/revolt/revolt.tester.js @@ -1,5 +1,5 @@ -import Joi from 'joi' import { createServiceTester } from '../tester.js' +import { isMetricWithPattern } from '../test-validators.js' export const t = await createServiceTester() @@ -7,7 +7,7 @@ t.create('get status of #revolt') .get('/01F7ZSBSFHQ8TA81725KQCSDDP.json') .expectBadge({ label: 'chat', - message: Joi.string().regex(/^[0-9]+ members$/), + message: isMetricWithPattern(/ members/), color: 'brightgreen', }) @@ -17,7 +17,7 @@ t.create('custom api url') ) .expectBadge({ label: 'chat', - message: Joi.string().regex(/^[0-9]+ members$/), + message: isMetricWithPattern(/ members/), color: 'brightgreen', })