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 c898267
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,30 @@ 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/,
});
});
});

const testedPackageManagers: Array<[string, string]> = [
[`yarn`, `1.22.4`],
[`yarn`, `1.22.4+sha1.01c1197ca5b27f21edc8bc472cd4c8ce0e5a470e`],
Expand Down

0 comments on commit c898267

Please sign in to comment.