From 0934126b51b4a55707408b1f86e2405b3d3fdc99 Mon Sep 17 00:00:00 2001 From: chris48s Date: Fri, 20 Dec 2024 11:42:09 +0000 Subject: [PATCH] use isDecimalPercentage in tests for github/lab top lang --- services/github/github-top-language.tester.js | 13 ++++++------- services/gitlab/gitlab-top-language.tester.js | 12 +++++------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/services/github/github-top-language.tester.js b/services/github/github-top-language.tester.js index 5bfea8d71299a..e4d84e1f5a439 100644 --- a/services/github/github-top-language.tester.js +++ b/services/github/github-top-language.tester.js @@ -1,13 +1,12 @@ -import Joi from 'joi' import { createServiceTester } from '../tester.js' +import { isDecimalPercentage } from '../test-validators.js' + export const t = await createServiceTester() -t.create('top language') - .get('/badges/shields.json') - .expectBadge({ - label: 'javascript', - message: Joi.string().regex(/^([1-9]?[0-9]\.[0-9]|100\.0)%$/), - }) +t.create('top language').get('/badges/shields.json').expectBadge({ + label: 'javascript', + message: isDecimalPercentage, +}) t.create('top language (empty repo)') .get('/pyvesb/emptyrepo.json') diff --git a/services/gitlab/gitlab-top-language.tester.js b/services/gitlab/gitlab-top-language.tester.js index 4fe19b38d80a7..43951fd615bbc 100644 --- a/services/gitlab/gitlab-top-language.tester.js +++ b/services/gitlab/gitlab-top-language.tester.js @@ -1,14 +1,12 @@ -import Joi from 'joi' import { createServiceTester } from '../tester.js' +import { isDecimalPercentage } from '../test-validators.js' export const t = await createServiceTester() -t.create('Valid Repository') - .get('/wireshark/wireshark.json') - .expectBadge({ - label: 'c', - message: Joi.string().regex(/^([1-9]?[0-9]\.[0-9]|100\.0)%$/), - }) +t.create('Valid Repository').get('/wireshark/wireshark.json').expectBadge({ + label: 'c', + message: isDecimalPercentage, +}) t.create('Valid Blank Repo') .get('/KoruptTinker/gitlab-blank-repo.json')