Template
1
0
mirror of https://github.com/actions/setup-node synced 2024-11-30 21:22:29 +08:00

tests: add test to check for corepack enable call

This commit is contained in:
Sayak Mukhopadhyay 2022-12-26 19:21:01 +05:30
parent 3e8819f8f2
commit b6efa7f903
No known key found for this signature in database
GPG Key ID: 89EEFF3FB23D3FFD

View File

@ -1253,6 +1253,44 @@ 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()
);
});
it('fails to use corepack with an invalid package manager', async () => {
await expect(im.enableCorepack('npm turbo')).rejects.toThrowError(
`One or more of the specified package managers [ npm turbo ] are not supported by corepack`
);
});
});
}); });
describe('helper methods', () => { describe('helper methods', () => {