Skip to content

Commit

Permalink
chore: add test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
zhyupe committed Feb 24, 2024
1 parent b143117 commit 7423405
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions tests/main.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -758,3 +758,46 @@ it(`should be able to show the latest version`, async () => {
});
});
});

it(`should download yarn classic from custom registry`, async () => {
await xfs.mktempPromise(async cwd => {
process.env.COREPACK_NPM_REGISTRY = `https://registry.npmmirror.com`;
process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT = `1`;
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 0,
stdout: /^1\.\d+\.\d+\r?\n$/,
stderr: /^Corepack is about to download https:\/\/registry\.npmmirror\.com\/yarn\/-\/yarn-1\.\d+\.\d+\.tgz\r?\n$/,
});

// Should keep working with cache
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 0,
stdout: /^1\.\d+\.\d+\r?\n$/,
stderr: ``,
});
});
});

it(`should download yarn berry from custom registry`, async () => {
await xfs.mktempPromise(async cwd => {
process.env.COREPACK_NPM_REGISTRY = `https://registry.npmmirror.com`;
process.env.COREPACK_ENABLE_DOWNLOAD_PROMPT = `1`;

await xfs.writeJsonPromise(ppath.join(cwd, `package.json` as Filename), {
packageManager: `[email protected]`,
});

await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 0,
stdout: `3.0.0\n`,
stderr: `Corepack is about to download https://registry.npmmirror.com/@yarnpkg/cli-dist/-/cli-dist-3.0.0.tgz\n`,
});

// Should keep working with cache
await expect(runCli(cwd, [`yarn`, `--version`])).resolves.toMatchObject({
exitCode: 0,
stdout: `3.0.0\n`,
stderr: ``,
});
});
});

0 comments on commit 7423405

Please sign in to comment.