From 7c0fdd03f544655a07e8bf1ab1f0873d1306a784 Mon Sep 17 00:00:00 2001 From: Jacob Parish Date: Tue, 21 Nov 2023 13:31:24 -0600 Subject: [PATCH] test: updated tests --- __tests__/main.test.ts | 52 ++++++++++++++++++++++++++++ __tests__/official-installer.test.ts | 32 ----------------- 2 files changed, 52 insertions(+), 32 deletions(-) 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() - ); - }); - }); });