import { expect } from 'chai'; import * as sinon from 'sinon'; import {DoesNotExistException} from '@aws-sdk/client-ssm' import { ParameterStoreService, ssm } from '../src/services/parameterStoreService'; const target = new ParameterStoreService(); describe('Tests suite - Parameter Store Service.', () => { afterEach('After each test', async () => { sinon.restore(); }); it('SUCCESS: Get Secret.', async () => { const secret = { username: 'test', password: 'test', }; const Value = JSON.stringify(secret); sinon.stub(ssm, 'send').resolves({ Parameter: { Value, }, }); const response = await target.getPartnerParameters(); expect(response).to.deep.equal(secret); }); it('ERROR: Get Secret.', async () => { const error = new DoesNotExistException({ message: 'Parameter not found', } as any); sinon.stub(ssm, 'send').rejects(error); try { await target.getPartnerParameters(); } catch (error) { expect(error).to.be.instanceOf(DoesNotExistException); } }); });