From c898267d854691b641c9b1f64cd4cb08dfc6b553 Mon Sep 17 00:00:00 2001 From: merceyz Date: Sun, 8 Oct 2023 16:28:02 +0200 Subject: [PATCH] test: check that a semver version is required --- tests/main.test.ts | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/tests/main.test.ts b/tests/main.test.ts index f72a97fb6..9840deb6c 100644 --- a/tests/main.test.ts +++ b/tests/main.test.ts @@ -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`],