From e8501859aa05b6b71ff73e66a11c30973f9e01ff Mon Sep 17 00:00:00 2001 From: IvanZosimov Date: Mon, 15 May 2023 14:24:28 +0200 Subject: [PATCH] Update unit tests --- __tests__/installer.test.ts | 51 +++++++++++++++++++++++++++++-------- 1 file changed, 41 insertions(+), 10 deletions(-) diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index 4694e5d..0d264b5 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -48,8 +48,13 @@ describe('installer tests', () => { it('should return version of .NET SDK after installation complete', async () => { const inputVersion = '3.1.100'; const inputQuality = '' as QualityOptions; + const stdout = `Fictitious dotnet version ${inputVersion} is installed`; getExecOutputSpy.mockImplementation(() => { - return Promise.resolve({exitCode: 0, stdout: '', stderr: ''}); + return Promise.resolve({ + exitCode: 0, + stdout: `${stdout}`, + stderr: '' + }); }); maxSatisfyingSpy.mockImplementation(() => inputVersion); @@ -65,9 +70,14 @@ describe('installer tests', () => { it(`should supply 'version' argument to the installation script if supplied version is in A.B.C syntax`, async () => { const inputVersion = '6.0.300'; const inputQuality = '' as QualityOptions; + const stdout = `Fictitious dotnet version ${inputVersion} is installed`; getExecOutputSpy.mockImplementation(() => { - return Promise.resolve({exitCode: 0, stdout: '', stderr: ''}); + return Promise.resolve({ + exitCode: 0, + stdout: `${stdout}`, + stderr: '' + }); }); maxSatisfyingSpy.mockImplementation(() => inputVersion); @@ -91,9 +101,13 @@ describe('installer tests', () => { it(`should warn if the 'quality' input is set and the supplied version is in A.B.C syntax`, async () => { const inputVersion = '6.0.300'; const inputQuality = 'ga' as QualityOptions; - + const stdout = `Fictitious dotnet version ${inputVersion} is installed`; getExecOutputSpy.mockImplementation(() => { - return Promise.resolve({exitCode: 0, stdout: '', stderr: ''}); + return Promise.resolve({ + exitCode: 0, + stdout: `${stdout}`, + stderr: '' + }); }); maxSatisfyingSpy.mockImplementation(() => inputVersion); @@ -112,9 +126,14 @@ describe('installer tests', () => { it(`should warn if the 'quality' input is set and version isn't in A.B.C syntax but major tag is lower then 6`, async () => { const inputVersion = '3.1'; const inputQuality = 'ga' as QualityOptions; + const stdout = `Fictitious dotnet version 3.1.100 is installed`; getExecOutputSpy.mockImplementation(() => { - return Promise.resolve({exitCode: 0, stdout: '', stderr: ''}); + return Promise.resolve({ + exitCode: 0, + stdout: `${stdout}`, + stderr: '' + }); }); maxSatisfyingSpy.mockImplementation(() => inputVersion); @@ -135,10 +154,11 @@ describe('installer tests', () => { async inputVersion => { const inputQuality = 'ga' as QualityOptions; const exitCode = 0; + const stdout = `Fictitious dotnet version 6.0.0 is installed`; getExecOutputSpy.mockImplementation(() => { return Promise.resolve({ exitCode: exitCode, - stdout: '', + stdout: `${stdout}`, stderr: '' }); }); @@ -167,10 +187,11 @@ describe('installer tests', () => { async inputVersion => { const inputQuality = '' as QualityOptions; const exitCode = 0; + const stdout = `Fictitious dotnet version 6.0.0 is installed`; getExecOutputSpy.mockImplementation(() => { return Promise.resolve({ exitCode: exitCode, - stdout: '', + stdout: `${stdout}`, stderr: '' }); }); @@ -199,9 +220,14 @@ describe('installer tests', () => { process.env['https_proxy'] = 'https://proxy.com'; const inputVersion = '6.0.100'; const inputQuality = '' as QualityOptions; + const stdout = `Fictitious dotnet version ${inputVersion} is installed`; getExecOutputSpy.mockImplementation(() => { - return Promise.resolve({exitCode: 0, stdout: '', stderr: ''}); + return Promise.resolve({ + exitCode: 0, + stdout: `${stdout}`, + stderr: '' + }); }); maxSatisfyingSpy.mockImplementation(() => inputVersion); @@ -225,9 +251,14 @@ describe('installer tests', () => { process.env['no_proxy'] = 'first.url,second.url'; const inputVersion = '6.0.100'; const inputQuality = '' as QualityOptions; + const stdout = `Fictitious dotnet version 6.0.0 is installed`; getExecOutputSpy.mockImplementation(() => { - return Promise.resolve({exitCode: 0, stdout: '', stderr: ''}); + return Promise.resolve({ + exitCode: 0, + stdout: `${stdout}`, + stderr: '' + }); }); maxSatisfyingSpy.mockImplementation(() => inputVersion); @@ -396,4 +427,4 @@ describe('installer tests', () => { ); }); }); -}); \ No newline at end of file +});