diff --git a/__tests__/main.test.ts b/__tests__/main.test.ts index b5724875..e7d92a51 100644 --- a/__tests__/main.test.ts +++ b/__tests__/main.test.ts @@ -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() + ); + }); + }); }); diff --git a/__tests__/official-installer.test.ts b/__tests__/official-installer.test.ts index 778b5196..2d36c19c 100644 --- a/__tests__/official-installer.test.ts +++ b/__tests__/official-installer.test.ts @@ -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() - ); - }); - }); });