Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added option to enable corepack #901

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Prev Previous commit
Next Next commit
test: updated tests
  • Loading branch information
jrparish committed Nov 21, 2023
commit 7c0fdd03f544655a07e8bf1ab1f0873d1306a784
52 changes: 52 additions & 0 deletions __tests__/main.test.ts
Original file line number Diff line number Diff line change
@@ -300,4 +300,56 @@ describe('main tests', () => {
);
});
});

describe('corepack flag', () => {
it('should not enable corepack when no input', async () => {
inputs['corepack'] = '';
await main.run();
expect(getExecOutputSpy).not.toHaveBeenCalledWith(
'corepack',
expect.anything(),
expect.anything()
);
});

it('should not enable corepack when input is "false"', async () => {
inputs['corepack'] = 'false';
await main.run();
expect(getExecOutputSpy).not.toHaveBeenCalledWith(
'corepack',
expect.anything(),
expect.anything()
);
});

it('should enable corepack when input is "true"', async () => {
inputs['corepack'] = 'true';
await main.run();
expect(getExecOutputSpy).toHaveBeenCalledWith(
'corepack',
['enable'],
expect.anything()
);
});

it('should enable corepack with a single package manager', async () => {
inputs['corepack'] = 'npm';
await main.run();
expect(getExecOutputSpy).toHaveBeenCalledWith(
'corepack',
['enable', 'npm'],
expect.anything()
);
});

it('should enable corepack with multiple package managers', async () => {
inputs['corepack'] = 'npm yarn';
await main.run();
expect(getExecOutputSpy).toHaveBeenCalledWith(
'corepack',
['enable', 'npm', 'yarn'],
expect.anything()
);
});
});
});
32 changes: 0 additions & 32 deletions __tests__/official-installer.test.ts
Original file line number Diff line number Diff line change
@@ -825,36 +825,4 @@ describe('setup-node', () => {
}
);
});

describe('corepack flag', () => {
it('use corepack if specified', async () => {
inputs['corepack'] = 'true';
await main.run();
expect(getExecOutputSpy).toHaveBeenCalledWith(
'corepack',
['enable'],
expect.anything()
);
});

it('use corepack with given package manager', async () => {
inputs['corepack'] = 'npm';
await main.run();
expect(getExecOutputSpy).toHaveBeenCalledWith(
'corepack',
['enable', 'npm'],
expect.anything()
);
});

it('use corepack with multiple package managers', async () => {
inputs['corepack'] = 'npm yarn';
await main.run();
expect(getExecOutputSpy).toHaveBeenCalledWith(
'corepack',
['enable', 'npm', 'yarn'],
expect.anything()
);
});
});
});