mirror of
https://github.com/azure/login.git
synced 2026-03-12 18:07:08 -04:00
* Added unit tests for Azure PowerShell * Added unit tests * changes in utils * removed babel * changed variable name of enable-PSSession * refactor * added ci.yml * changes in utils test
40 lines
1.2 KiB
TypeScript
40 lines
1.2 KiB
TypeScript
import { ServicePrincipalLogin } from '../../src/PowerShell/ServicePrincipalLogin';
|
|
|
|
jest.mock('../../src/PowerShell/Utilities/Utils');
|
|
jest.mock('../../src/PowerShell/Utilities/PowerShellToolRunner');
|
|
let spnlogin: ServicePrincipalLogin;
|
|
|
|
beforeAll(() => {
|
|
spnlogin = new ServicePrincipalLogin("servicePrincipalID", "servicePrinicipalkey", "tenantId", "subscriptionId");
|
|
});
|
|
|
|
afterEach(() => {
|
|
jest.restoreAllMocks();
|
|
});
|
|
|
|
describe('Testing initialize', () => {
|
|
let initializeSpy;
|
|
|
|
beforeEach(() => {
|
|
initializeSpy = jest.spyOn(spnlogin, 'initialize');
|
|
});
|
|
test('ServicePrincipalLogin initialize should pass', async () => {
|
|
await spnlogin.initialize();
|
|
expect(initializeSpy).toHaveBeenCalled();
|
|
});
|
|
});
|
|
|
|
describe('Testing login', () => {
|
|
let loginSpy;
|
|
|
|
beforeEach(() => {
|
|
loginSpy = jest.spyOn(spnlogin, 'login');
|
|
});
|
|
test('ServicePrincipal login should pass', async () => {
|
|
loginSpy.mockImplementationOnce(() => Promise.resolve(
|
|
console.log('Azure PowerShell session successfully initialized')));
|
|
await spnlogin.login();
|
|
expect(loginSpy).toHaveBeenCalled();
|
|
});
|
|
});
|