Skip to content

Commit 00a0dc4

Browse files
committed
test: check that a semver version is required
1 parent adf2e7a commit 00a0dc4

File tree

4 files changed

+34
-0
lines changed

4 files changed

+34
-0
lines changed

tests/main.test.ts

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,40 @@ it(`should refuse to download a package manager if the hash doesn't match`, asyn
2929
});
3030
});
3131

32+
it(`should require a version to be specified`, async () => {
33+
await xfs.mktempPromise(async cwd => {
34+
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), {
35+
packageManager: `yarn`,
36+
});
37+
38+
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
39+
exitCode: 1,
40+
stderr: ``,
41+
stdout: /expected a semver version/,
42+
});
43+
44+
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), {
45+
packageManager: `yarn@stable`,
46+
});
47+
48+
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
49+
exitCode: 1,
50+
stderr: ``,
51+
stdout: /expected a semver version/,
52+
});
53+
54+
await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), {
55+
packageManager: `yarn@^1.0.0`,
56+
});
57+
58+
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
59+
exitCode: 1,
60+
stderr: ``,
61+
stdout: /expected a semver version/,
62+
});
63+
});
64+
});
65+
3266
const testedPackageManagers: Array<[string, string]> = [
3367
[`yarn`, `1.22.4`],
3468
[`yarn`, `1.22.4+sha1.01c1197ca5b27f21edc8bc472cd4c8ce0e5a470e`],
7 Bytes
Binary file not shown.
7 Bytes
Binary file not shown.
7 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)