UNPKG

oprah

Version:

Package to deploy parameters to AWS

37 lines (29 loc) 882 B
const AWS = require('aws-sdk'); const mockGetCallIdentity = jest.fn(); AWS.STS.mockImplementation(() => ({ getCallerIdentity: mockGetCallIdentity })); const { getAccountId } = require('./get-account-id'); describe('getAccountId', () => { it('should get the account Id', () => { mockGetCallIdentity.mockImplementation(() => ({ promise: () => Promise.resolve({ Account: '12344556', Arn: 'eyAreEn', UserId: 'useruserId' }) })); return expect(getAccountId()).resolves.toEqual('12344556'); }); it('should throw if the account Id is missing', () => { mockGetCallIdentity.mockImplementation(() => ({ promise: () => Promise.resolve({ Arn: 'eyAreEn', UserId: 'useruserId' }) })); return expect(getAccountId()).rejects.toThrow('Missing accountId'); }); });