From 4b20cd3fb1890660294a21a9fbd562fd769fc13c Mon Sep 17 00:00:00 2001 From: Nikolai Laevskii Date: Mon, 4 Sep 2023 07:24:15 +0200 Subject: [PATCH] Update unit-tests --- __tests__/installer.test.ts | 44 +++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/__tests__/installer.test.ts b/__tests__/installer.test.ts index 49666e0..89ffea9 100644 --- a/__tests__/installer.test.ts +++ b/__tests__/installer.test.ts @@ -125,6 +125,50 @@ describe('installer tests', () => { expect(scriptArguments).toContain(expectedArgument); }); + it(`should supply 'runtime' argument to the installation script if runtimeOnly parameter is true`, async () => { + const inputVersion = '6.0.300'; + const inputQuality = '' as QualityOptions; + const stdout = `Fictitious dotnet version ${inputVersion} is installed`; + + const resolvedVersion = await new installer.DotnetVersionResolver( + inputVersion + ).createDotnetVersion(); + + getExecOutputSpy.mockImplementation(() => { + return Promise.resolve({ + exitCode: 0, + stdout: `${stdout}`, + stderr: '' + }); + }); + maxSatisfyingSpy.mockImplementation(() => inputVersion); + + const dotnetInstaller = new installer.DotnetCoreInstaller( + resolvedVersion, + inputQuality, + true + ); + + await dotnetInstaller.installDotnet(); + + /** + * First time script would be called to + * install runtime of the latest version in order + * to provide latest CLI, here we are checking only the + * second one that installs actual requested runtime + */ + const callIndex = 1; + + const scriptArguments = ( + getExecOutputSpy.mock.calls[callIndex][1] as string[] + ).join(' '); + const expectedArgument = IS_WINDOWS + ? `-Runtime` + : `--runtime`; + + expect(scriptArguments).toContain(expectedArgument); + }); + 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;