From 9fd0bd9c2e7e9fe78bee5c91b9c59f0f21932edd Mon Sep 17 00:00:00 2001 From: Pierre Cavin Date: Sat, 18 Nov 2023 17:15:44 +0100 Subject: [PATCH] test: remove superfluous semVerRegexLine test case --- lib/helpers/regexes.js | 4 ++-- lib/helpers/regexes.spec.js | 22 +--------------------- 2 files changed, 3 insertions(+), 23 deletions(-) diff --git a/lib/helpers/regexes.js b/lib/helpers/regexes.js index d4bc2fa..0d33e5e 100644 --- a/lib/helpers/regexes.js +++ b/lib/helpers/regexes.js @@ -1,5 +1,5 @@ -// source: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string -export const semVerRegexLine = new RegExp( +/** source: https://semver.org/#is-there-a-suggested-regular-expression-regex-to-check-a-semver-string */ +const semVerRegexLine = new RegExp( /^(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/, ); const semVerRegex = new RegExp(semVerRegexLine.source.replace(/[\^$]/g, "")); diff --git a/lib/helpers/regexes.spec.js b/lib/helpers/regexes.spec.js index 3456da1..aba2d8f 100644 --- a/lib/helpers/regexes.spec.js +++ b/lib/helpers/regexes.spec.js @@ -2,27 +2,7 @@ import { invalidSemVers, validSemVers, } from "../../tests/fixtures/regexes.fixture"; -import { semVerRegexLine, versionRegex } from "./regexes"; - -describe("semVerRegexLine", () => { - it("should match valid values", () => { - // eslint-disable-next-line jest/prefer-expect-assertions - expect.assertions(validSemVers.length); - - for (let semVer of validSemVers) { - expect(semVer).toMatch(semVerRegexLine); - } - }); - - it("should not match invalid values", () => { - // eslint-disable-next-line jest/prefer-expect-assertions - expect.assertions(invalidSemVers.length); - - for (let semVer of invalidSemVers) { - expect(semVer).not.toMatch(semVerRegexLine); - } - }); -}); +import { versionRegex } from "./regexes"; describe("versionRegex", () => { it("should match valid values", () => {