From e084b46b622fdbefcdeb6276ab5c9937c218c981 Mon Sep 17 00:00:00 2001 From: Christophe Hurpeau <302891+christophehurpeau@users.noreply.github.com> Date: Fri, 26 Apr 2024 21:39:45 +0200 Subject: [PATCH] test: add test changeOperator --- package.json | 2 +- .../checkSatisfiesVersionsFromDependency.test.ts | 7 +++++++ src/utils/semverUtils.test.ts | 8 ++++++++ yarn.lock | 11 ++--------- 4 files changed, 18 insertions(+), 10 deletions(-) create mode 100644 src/utils/semverUtils.test.ts diff --git a/package.json b/package.json index 733ee827..b025aa34 100644 --- a/package.json +++ b/package.json @@ -85,7 +85,7 @@ "@pob/eslint-config-typescript": "55.2.1", "@pob/rollup-esbuild": "1.0.1", "@pob/root": "9.3.2", - "@types/semver": "7.5.6", + "@types/semver": "7.5.8", "@types/semver-utils": "1.1.3", "@vitest/coverage-v8": "1.5.2", "eslint": "8.57.0", diff --git a/src/checks/checkSatisfiesVersionsFromDependency.test.ts b/src/checks/checkSatisfiesVersionsFromDependency.test.ts index d3edffe4..e1246cd1 100644 --- a/src/checks/checkSatisfiesVersionsFromDependency.test.ts +++ b/src/checks/checkSatisfiesVersionsFromDependency.test.ts @@ -134,6 +134,13 @@ describe(checkSatisfiesVersionsFromDependency.name, () => { { devDependencies: { expectedDep: '^1.0.1' } }, true, ], + [ + 'expects range version with existing version ; shouldHaveExactVersions = false ; with release', + '^1.0.1-beta', + { devDependencies: { expectedDep: '^1.0.0' } }, + { devDependencies: { expectedDep: '^1.0.1-beta' } }, + false, + ], ])( 'should to fix when %s', ( diff --git a/src/utils/semverUtils.test.ts b/src/utils/semverUtils.test.ts new file mode 100644 index 00000000..b1c44a72 --- /dev/null +++ b/src/utils/semverUtils.test.ts @@ -0,0 +1,8 @@ +import { describe, expect, it } from 'vitest'; +import { changeOperator } from './semverUtils'; + +describe('changeOperator', () => { + it('should change the operator', () => { + expect(changeOperator('^1.0.1-beta', '~')).toBe('~1.0.1-beta'); + }); +}); diff --git a/yarn.lock b/yarn.lock index 84dd0a96..f4c08805 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1033,14 +1033,7 @@ __metadata: languageName: node linkType: hard -"@types/semver@npm:7.5.6": - version: 7.5.6 - resolution: "@types/semver@npm:7.5.6" - checksum: 10/e77282b17f74354e17e771c0035cccb54b94cc53d0433fa7e9ba9d23fd5d7edcd14b6c8b7327d58bbd89e83b1c5eda71dfe408e06b929007e2b89586e9b63459 - languageName: node - linkType: hard - -"@types/semver@npm:^7.5.8": +"@types/semver@npm:7.5.8, @types/semver@npm:^7.5.8": version: 7.5.8 resolution: "@types/semver@npm:7.5.8" checksum: 10/3496808818ddb36deabfe4974fd343a78101fa242c4690044ccdc3b95dcf8785b494f5d628f2f47f38a702f8db9c53c67f47d7818f2be1b79f2efb09692e1178 @@ -1741,7 +1734,7 @@ __metadata: "@pob/eslint-config-typescript": "npm:55.2.1" "@pob/rollup-esbuild": "npm:1.0.1" "@pob/root": "npm:9.3.2" - "@types/semver": "npm:7.5.6" + "@types/semver": "npm:7.5.8" "@types/semver-utils": "npm:1.1.3" "@vitest/coverage-v8": "npm:1.5.2" chalk: "npm:^5.2.0"