diff --git a/packages/connectors-lib/src/__tests__/aws.spec.js b/packages/connectors-lib/src/__tests__/aws.spec.js index 0baf880d2..ca81976b5 100644 --- a/packages/connectors-lib/src/__tests__/aws.spec.js +++ b/packages/connectors-lib/src/__tests__/aws.spec.js @@ -4,13 +4,13 @@ import { DynamoDBDocument } from '@aws-sdk/lib-dynamodb' import Config from '../config' jest.mock('aws-sdk', () => { - const SQS = jest.fn().mockImplementation((config) => ({ + const SQS = jest.fn().mockImplementation(config => ({ config: { ...config, apiVersion: '2012-11-05', region: config.region || 'eu-west-2' } })) - const S3 = jest.fn().mockImplementation((config) => ({ + const S3 = jest.fn().mockImplementation(config => ({ config: { ...config, apiVersion: '2006-03-01', region: config.region || 'eu-west-2', s3ForcePathStyle: config.s3ForcePathStyle } })) - const SecretsManager = jest.fn().mockImplementation((config) => ({ + const SecretsManager = jest.fn().mockImplementation(config => ({ config: { ...config, apiVersion: '2017-10-17', region: config.region || 'eu-west-2' } })) @@ -52,9 +52,11 @@ describe('AWS Connectors', () => { const TEST_ENDPOINT = 'http://localhost:8080' Config.aws.dynamodb.endpoint = TEST_ENDPOINT require('../aws.js').default() - expect(DynamoDB).toHaveBeenCalledWith(expect.objectContaining({ - endpoint: TEST_ENDPOINT - })) + expect(DynamoDB).toHaveBeenCalledWith( + expect.objectContaining({ + endpoint: TEST_ENDPOINT + }) + ) expect(DynamoDBDocument.from).toHaveBeenCalledWith(expect.any(DynamoDB)) }) @@ -62,9 +64,11 @@ describe('AWS Connectors', () => { process.env.AWS_REGION = 'eu-west-2' delete Config.aws.dynamodb.endpoint require('../aws.js').default() - expect(DynamoDB).toHaveBeenCalledWith(expect.objectContaining({ - region: 'eu-west-2' - })) + expect(DynamoDB).toHaveBeenCalledWith( + expect.objectContaining({ + region: 'eu-west-2' + }) + ) expect(DynamoDBDocument.from).toHaveBeenCalledWith(expect.any(DynamoDB)) }) @@ -72,57 +76,69 @@ describe('AWS Connectors', () => { const TEST_ENDPOINT = 'http://localhost:8080' Config.aws.sqs.endpoint = TEST_ENDPOINT require('../aws.js').default() - expect(SQS).toHaveBeenCalledWith(expect.objectContaining({ - endpoint: TEST_ENDPOINT, - region: 'eu-west-2' - })) + expect(SQS).toHaveBeenCalledWith( + expect.objectContaining({ + endpoint: TEST_ENDPOINT, + region: 'eu-west-2' + }) + ) }) it('uses the default sqs endpoint if it is not overridden in configuration', () => { process.env.AWS_REGION = 'eu-west-2' delete Config.aws.sqs.endpoint require('../aws.js').default() - expect(SQS).toHaveBeenCalledWith(expect.objectContaining({ - region: 'eu-west-2' - })) + expect(SQS).toHaveBeenCalledWith( + expect.objectContaining({ + region: 'eu-west-2' + }) + ) }) it('configures s3 with a custom endpoint if one is defined in configuration', () => { const TEST_ENDPOINT = 'http://localhost:8080' Config.aws.s3.endpoint = TEST_ENDPOINT require('../aws.js').default() - expect(S3).toHaveBeenCalledWith(expect.objectContaining({ - endpoint: TEST_ENDPOINT, - s3ForcePathStyle: true, - region: 'eu-west-2' - })) + expect(S3).toHaveBeenCalledWith( + expect.objectContaining({ + endpoint: TEST_ENDPOINT, + s3ForcePathStyle: true, + region: 'eu-west-2' + }) + ) }) it('uses default s3 settings if a custom endpoint is not defined', () => { process.env.AWS_REGION = 'eu-west-2' delete Config.aws.s3.endpoint require('../aws.js').default() - expect(S3).toHaveBeenCalledWith(expect.objectContaining({ - region: 'eu-west-2' - })) + expect(S3).toHaveBeenCalledWith( + expect.objectContaining({ + region: 'eu-west-2' + }) + ) }) it('configures secretsmanager with a custom endpoint if one is defined in configuration', () => { const TEST_ENDPOINT = 'http://localhost:8080' Config.aws.secretsManager.endpoint = TEST_ENDPOINT require('../aws.js').default() - expect(SecretsManager).toHaveBeenCalledWith(expect.objectContaining({ - endpoint: TEST_ENDPOINT, - region: 'eu-west-2' - })) + expect(SecretsManager).toHaveBeenCalledWith( + expect.objectContaining({ + endpoint: TEST_ENDPOINT, + region: 'eu-west-2' + }) + ) }) it('uses default secretsmanager settings if a custom endpoint is not defined', () => { process.env.AWS_REGION = 'eu-west-2' delete Config.aws.secretsManager.endpoint require('../aws.js').default() - expect(SecretsManager).toHaveBeenCalledWith(expect.objectContaining({ - region: 'eu-west-2' - })) + expect(SecretsManager).toHaveBeenCalledWith( + expect.objectContaining({ + region: 'eu-west-2' + }) + ) }) })