diff --git a/tests/main.test.ts b/tests/main.test.ts index f72a97fb6..3538ff3dd 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -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`], diff --git a/tests/nock/xMfDvY4klJ8hOhDDO0NK5A-1.dat b/tests/nock/xMfDvY4klJ8hOhDDO0NK5A-1.dat new file mode 100644 index 000000000..b03652e61 Binary files /dev/null and b/tests/nock/xMfDvY4klJ8hOhDDO0NK5A-1.dat differ diff --git a/tests/nock/xMfDvY4klJ8hOhDDO0NK5A-2.dat b/tests/nock/xMfDvY4klJ8hOhDDO0NK5A-2.dat new file mode 100644 index 000000000..b03652e61 Binary files /dev/null and b/tests/nock/xMfDvY4klJ8hOhDDO0NK5A-2.dat differ diff --git a/tests/nock/xMfDvY4klJ8hOhDDO0NK5A-3.dat b/tests/nock/xMfDvY4klJ8hOhDDO0NK5A-3.dat new file mode 100644 index 000000000..b03652e61 Binary files /dev/null and b/tests/nock/xMfDvY4klJ8hOhDDO0NK5A-3.dat differ