Skip to content

Commit c7fc941

Browse files
authored
Add test fixture to capture all known types of versions (#519)
* test: add test fixture to capture all known types of versions * add more version types
1 parent fdbde1c commit c7fc941

File tree

4 files changed

+87
-0
lines changed

4 files changed

+87
-0
lines changed
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"workspaces": [
3+
"*"
4+
],
5+
"//": "These dependencies should match the versions in the other package.json in this fixture.",
6+
"dependencies": {
7+
"semver1": "1",
8+
"semver2": "1.0.0",
9+
"semver3": "1.0.0-0",
10+
"semver4": "~1",
11+
"semver5": "^1",
12+
"semver6": "^1.0.0",
13+
"semver7": "1.x",
14+
"file1": "file:/",
15+
"file2": "file:packages/a",
16+
"file3": "file:./packages/a",
17+
"file4": "file:../foo",
18+
"patch1": "patch:[email protected]#./patches/c+1.3.0.patch",
19+
"git1": "git+ssh://[email protected]:org/repo.git#v1.2.0",
20+
"git2": "git+https://github.com/user/repo.git#commit123abc",
21+
"git3": "https://url/repo.git",
22+
"git4": "http://asdf.com/asdf.tar.gz",
23+
"git5": "expressjs/express",
24+
"git6": "mochajs/mocha#4727d357ea",
25+
"git7": "user/repo#feature\/branch",
26+
"star": "*",
27+
"workspace1": "workspace:^",
28+
"workspace2": "workspace:*",
29+
"latest": "latest",
30+
"//": "some comment",
31+
"blank": "",
32+
"range1": "1.0.0 - 2.9999.9999",
33+
"range2": ">=1.0.2 <2.1.2",
34+
"range3": ">1.0.2 <=2.3.4",
35+
"range4": "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0"
36+
}
37+
}
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
{
2+
"name": "package1",
3+
"//": "These dependencies should match the versions in the other package.json in this fixture.",
4+
"dependencies": {
5+
"semver1": "1",
6+
"semver2": "1.0.0",
7+
"semver3": "1.0.0-0",
8+
"semver4": "~1",
9+
"semver5": "^1",
10+
"semver6": "^1.0.0",
11+
"semver7": "1.x",
12+
"file1": "file:/",
13+
"file2": "file:packages/a",
14+
"file3": "file:./packages/a",
15+
"file4": "file:../foo",
16+
"patch1": "patch:[email protected]#./patches/c+1.3.0.patch",
17+
"git1": "git+ssh://[email protected]:org/repo.git#v1.2.0",
18+
"git2": "git+https://github.com/user/repo.git#commit123abc",
19+
"git3": "https://url/repo.git",
20+
"git4": "http://asdf.com/asdf.tar.gz",
21+
"git5": "expressjs/express",
22+
"git6": "mochajs/mocha#4727d357ea",
23+
"git7": "user/repo#feature\/branch",
24+
"star": "*",
25+
"workspace1": "workspace:^",
26+
"workspace2": "workspace:*",
27+
"latest": "latest",
28+
"//": "some comment",
29+
"blank": "",
30+
"range1": "1.0.0 - 2.9999.9999",
31+
"range2": ">=1.0.2 <2.1.2",
32+
"range3": ">1.0.2 <=2.3.4",
33+
"range4": "<1.0.0 || >=2.3.1 <2.4.5 || >=2.5.2 <3.0.0"
34+
}
35+
}

test/fixtures/index.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,8 @@ export const FIXTURE_PATH_NESTED_WORKSPACES = join(
6161
'nested-workspaces'
6262
);
6363
export const FIXTURE_PATH_RESOLUTIONS = join(FIXTURE_PATH, 'resolutions');
64+
65+
export const FIXTURE_PATH_ALL_VERSION_TYPES = join(
66+
FIXTURE_PATH,
67+
'all-version-types'
68+
);

test/lib/dependency-versions-test.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ import {
1313
FIXTURE_PATH_PACKAGE_MISSING_PACKAGE_JSON,
1414
FIXTURE_PATH_INCONSISTENT_LOCAL_PACKAGE_VERSION,
1515
FIXTURE_PATH_RESOLUTIONS,
16+
FIXTURE_PATH_ALL_VERSION_TYPES,
1617
} from '../fixtures/index.js';
1718
import mockFs from 'mock-fs';
1819
import { readFileSync } from 'node:fs';
@@ -208,6 +209,15 @@ describe('Utils | dependency-versions', function () {
208209
},
209210
]);
210211
});
212+
213+
it('has no problem with all version types', function () {
214+
const dependencyVersions = calculateVersionsForEachDependency(
215+
getPackagesHelper(FIXTURE_PATH_ALL_VERSION_TYPES)
216+
);
217+
expect(calculateMismatchingVersions(dependencyVersions)).toStrictEqual(
218+
[]
219+
);
220+
});
211221
});
212222

213223
describe('#filterOutIgnoredDependencies', function () {

0 commit comments

Comments
 (0)