Skip to content

Commit

Permalink
test: add fixture for yarn berry version detect
Browse files Browse the repository at this point in the history
  • Loading branch information
pi0 committed Mar 29, 2023
1 parent 23dc546 commit 019a2ac
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/detect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const packageManagers: PackageManager[] = [
{
name: "yarn",
command: "yarn",
majorVersion: "2.0.0",
majorVersion: "3.0.0",
lockFile: "yarn.lock",
files: [".yarnrc.yml"],
},
Expand Down
3 changes: 3 additions & 0 deletions test/fixtures/yarn-berry/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.yarn
!.yarn/releases
.pnp.cjs
1 change: 1 addition & 0 deletions test/fixtures/yarn-berry/.yarnrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
yarnPath: .yarn/releases/yarn-3.5.0.cjs
2 changes: 1 addition & 1 deletion test/fixtures/yarn-berry/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"dependencies": {
"pathe": "^1.1.0"
},
"packageManager": "yarn@1.22.19",
"packageManager": "yarn@3.5.0",
"devDependencies": {
"ufo": "^1.1.1"
}
Expand Down
36 changes: 26 additions & 10 deletions test/fixtures/yarn-berry/yarn.lock
Original file line number Diff line number Diff line change
@@ -1,13 +1,29 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
# This file is generated by running "yarn install" inside your project.
# Manual changes might be lost - proceed with caution!

__metadata:
version: 6
cacheKey: 8

pathe@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/pathe/-/pathe-1.1.0.tgz#e2e13f6c62b31a3289af4ba19886c230f295ec03"
integrity sha512-ODbEPR0KKHqECXW1GoxdDb+AZvULmXjVPy4rt+pGo2+TnjJTIPJQSVS6N63n8T2Ip+syHhbn52OewKicV0373w==
"fixture-yarn@workspace:.":
version: 0.0.0-use.local
resolution: "fixture-yarn@workspace:."
dependencies:
pathe: ^1.1.0
ufo: ^1.1.1
languageName: unknown
linkType: soft

ufo@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/ufo/-/ufo-1.1.1.tgz#e70265e7152f3aba425bd013d150b2cdf4056d7c"
integrity sha512-MvlCc4GHrmZdAllBc0iUDowff36Q9Ndw/UzqmEKyrfSzokTd9ZCy1i+IIk5hrYKkjoYVQyNbrw7/F8XJ2rEwTg==
"pathe@npm:^1.1.0":
version: 1.1.0
resolution: "pathe@npm:1.1.0"
checksum: 6b9be9968ea08a90c0824934799707a1c6a1ad22ac1f22080f377e3f75856d5e53a331b01d327329bfce538a14590587cfb250e8e7947f64408797c84c252056
languageName: node
linkType: hard

"ufo@npm:^1.1.1":
version: 1.1.1
resolution: "ufo@npm:1.1.1"
checksum: 6bd210ed93d8c0dedd76c456b1d1dfb0e3b08c2216ee6080e61f0f545de0bac24b3d3a5530cd6a403810855f8d8fc3922583965296142e04cfc287442635e6c7
languageName: node
linkType: hard
4 changes: 3 additions & 1 deletion test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ const fixtures = [
{
name: "yarn-classic",
pm: "yarn",
majorVersion: "1",
},
{
name: "yarn-berry",
pm: "yarn",
majorVersion: "3",
},
];

Expand All @@ -40,7 +42,7 @@ describe("detectPackageManager", () => {
});
expect(detected).toMatchObject({
name: fixture.pm,
version: expect.any(String),
majorVersion: fixture.majorVersion || expect.any(String),
});
});
});
Expand Down

0 comments on commit 019a2ac

Please sign in to comment.