Skip to content

Commit

Permalink
test: remove superfluous semVerRegexLine test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sheerlox committed Nov 18, 2023
1 parent 4ad0261 commit 9fd0bd9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 23 deletions.
4 changes: 2 additions & 2 deletions lib/helpers/regexes.js
Original file line number Diff line number Diff line change
@@ -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, ""));
Expand Down
22 changes: 1 addition & 21 deletions lib/helpers/regexes.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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", () => {
Expand Down

0 comments on commit 9fd0bd9

Please sign in to comment.