Skip to content

Commit

Permalink
test: check that a semver version is required
Browse files Browse the repository at this point in the history
  • Loading branch information
merceyz committed Oct 8, 2023
1 parent adf2e7a commit 00a0dc4
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,40 @@ it(`should refuse to download a package manager if the hash doesn't match`, asyn
});
});

it(`should require a version to be specified`, async () => {
await xfs.mktempPromise(async cwd => {
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), {
packageManager: `yarn`,
});

await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 1,
stderr: ``,
stdout: /expected a semver version/,
});

await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), {
packageManager: `yarn@stable`,
});

await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 1,
stderr: ``,
stdout: /expected a semver version/,
});

await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), {
packageManager: `yarn@^1.0.0`,
});

await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 1,
stderr: ``,
stdout: /expected a semver version/,
});
});
});

const testedPackageManagers: Array<[string, string]> = [
[`yarn`, `1.22.4`],
[`yarn`, `1.22.4+sha1.01c1197ca5b27f21edc8bc472cd4c8ce0e5a470e`],
Expand Down
Binary file added tests/nock/xMfDvY4klJ8hOhDDO0NK5A-1.dat
Binary file not shown.
Binary file added tests/nock/xMfDvY4klJ8hOhDDO0NK5A-2.dat
Binary file not shown.
Binary file added tests/nock/xMfDvY4klJ8hOhDDO0NK5A-3.dat
Binary file not shown.

0 comments on commit 00a0dc4

Please sign in to comment.