Update tests
This commit is contained in:
parent
89b480a0df
commit
427804d76a
|
@ -283,14 +283,14 @@ describe('installer tests', () => {
|
|||
describe('addToPath() tests', () => {
|
||||
it(`should export DOTNET_ROOT env.var with value from DOTNET_INSTALL_DIR env.var`, async () => {
|
||||
process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir';
|
||||
installer.DotnetCoreInstaller.addToPath();
|
||||
installer.DotnetInstallDir.addToPath();
|
||||
const dotnet_root = process.env['DOTNET_ROOT'];
|
||||
expect(dotnet_root).toBe(process.env['DOTNET_INSTALL_DIR']);
|
||||
});
|
||||
|
||||
it(`should export value from DOTNET_INSTALL_DIR env.var to the PATH`, async () => {
|
||||
process.env['DOTNET_INSTALL_DIR'] = 'fictitious/dotnet/install/dir';
|
||||
installer.DotnetCoreInstaller.addToPath();
|
||||
installer.DotnetInstallDir.addToPath();
|
||||
const path = process.env['PATH'];
|
||||
expect(path).toContain(process.env['DOTNET_INSTALL_DIR']);
|
||||
});
|
||||
|
|
|
@ -4,7 +4,7 @@ import semver from 'semver';
|
|||
import * as auth from '../src/authutil';
|
||||
|
||||
import * as setup from '../src/setup-dotnet';
|
||||
import {DotnetCoreInstaller} from '../src/installer';
|
||||
import {DotnetCoreInstaller, DotnetInstallDir} from '../src/installer';
|
||||
|
||||
describe('setup-dotnet tests', () => {
|
||||
const inputs = {} as any;
|
||||
|
@ -25,17 +25,19 @@ describe('setup-dotnet tests', () => {
|
|||
DotnetCoreInstaller.prototype,
|
||||
'installDotnet'
|
||||
);
|
||||
const addToPathSpy = jest.spyOn(DotnetCoreInstaller, 'addToPath');
|
||||
|
||||
const configAuthenticationSpy = jest.spyOn(auth, 'configAuthentication');
|
||||
const addToPathOriginal = DotnetInstallDir.addToPath;
|
||||
|
||||
describe('run() tests', () => {
|
||||
beforeEach(() => {
|
||||
DotnetInstallDir.addToPath = jest.fn();
|
||||
getMultilineInputSpy.mockImplementation(input => inputs[input as string]);
|
||||
getInputSpy.mockImplementation(input => inputs[input as string]);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
DotnetInstallDir.addToPath = addToPathOriginal;
|
||||
jest.clearAllMocks();
|
||||
jest.resetAllMocks();
|
||||
});
|
||||
|
@ -96,10 +98,9 @@ describe('setup-dotnet tests', () => {
|
|||
inputs['dotnet-quality'] = '';
|
||||
|
||||
installDotnetSpy.mockImplementation(() => Promise.resolve(''));
|
||||
addToPathSpy.mockImplementation(() => {});
|
||||
|
||||
await setup.run();
|
||||
expect(addToPathSpy).toHaveBeenCalledTimes(1);
|
||||
expect(DotnetInstallDir.addToPath).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it('should call auth.configAuthentication() if source-url input is provided', async () => {
|
||||
|
@ -140,10 +141,9 @@ describe('setup-dotnet tests', () => {
|
|||
installDotnetSpy.mockImplementation(() =>
|
||||
Promise.resolve(`${inputs['dotnet-version']}`)
|
||||
);
|
||||
addToPathSpy.mockImplementation(() => {});
|
||||
|
||||
await setup.run();
|
||||
expect(setOutputSpy).toHaveBeenCalledTimes(1);
|
||||
expect(DotnetInstallDir.addToPath).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it(`shouldn't call setOutput() if parsing dotnet-installer logs failed`, async () => {
|
||||
|
@ -151,7 +151,6 @@ describe('setup-dotnet tests', () => {
|
|||
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);
|
||||
|
@ -162,8 +161,6 @@ describe('setup-dotnet tests', () => {
|
|||
inputs['dotnet-version'] = [];
|
||||
const warningMessage = `The 'dotnet-version' output will not be set.`;
|
||||
|
||||
addToPathSpy.mockImplementation(() => {});
|
||||
|
||||
await setup.run();
|
||||
|
||||
expect(infoSpy).toHaveBeenCalledWith(warningMessage);
|
||||
|
|
Loading…
Reference in New Issue