mirror of
https://github.com/actions/setup-dotnet.git
synced 2025-04-06 23:39:47 +00:00
update unit and e2e tests
This commit is contained in:
@ -12,6 +12,7 @@ describe('setup-dotnet tests', () => {
|
||||
const getInputSpy = jest.spyOn(core, 'getInput');
|
||||
const getMultilineInputSpy = jest.spyOn(core, 'getMultilineInput');
|
||||
const setFailedSpy = jest.spyOn(core, 'setFailed');
|
||||
const warningSpy = jest.spyOn(core, 'warning');
|
||||
const debugSpy = jest.spyOn(core, 'debug');
|
||||
const infoSpy = jest.spyOn(core, 'info');
|
||||
const setOutputSpy = jest.spyOn(core, 'setOutput');
|
||||
@ -133,14 +134,40 @@ describe('setup-dotnet tests', () => {
|
||||
);
|
||||
});
|
||||
|
||||
it('should call setOutput() after installation complete', async () => {
|
||||
it('should call setOutput() after installation complete successfully', async () => {
|
||||
inputs['dotnet-version'] = ['6.0.300'];
|
||||
|
||||
installDotnetSpy.mockImplementation(() => Promise.resolve(''));
|
||||
installDotnetSpy.mockImplementation(() =>
|
||||
Promise.resolve(`${inputs['dotnet-version']}`)
|
||||
);
|
||||
addToPathSpy.mockImplementation(() => {});
|
||||
|
||||
await setup.run();
|
||||
expect(setOutputSpy).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it(`shouldn't call setOutput() if parsing dotnet-installer logs failed`, async () => {
|
||||
inputs['dotnet-version'] = ['6.0.300'];
|
||||
const warningMessage = `Failed to output the installed version of .NET. The 'dotnet-version' output will not be set.`;
|
||||
|
||||
installDotnetSpy.mockImplementation(() => Promise.resolve(null));
|
||||
addToPathSpy.mockImplementation(() => {});
|
||||
|
||||
await setup.run();
|
||||
expect(warningSpy).toHaveBeenCalledWith(warningMessage);
|
||||
expect(setOutputSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it(`shouldn't call setOutput() if actions didn't install .NET`, async () => {
|
||||
inputs['dotnet-version'] = [];
|
||||
const warningMessage = `No .NET version was installed. The 'dotnet-version' output will not be set.`;
|
||||
|
||||
addToPathSpy.mockImplementation(() => {});
|
||||
|
||||
await setup.run();
|
||||
|
||||
expect(infoSpy).toHaveBeenCalledWith(warningMessage);
|
||||
expect(setOutputSpy).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user