{"size": 2264, "ext": "js", "max_stars_repo_path": "source/lambda/layers/aws-nodesdk-custom-config/test/index.spec.js", "max_stars_repo_name": "swipswaps/discovering-hot-topics-using-machine-learning", "max_stars_repo_stars_event_min_datetime": "2021-09-25T10:14:30.000Z", "max_stars_repo_stars_event_max_datetime": "2022-02-14T10:45:00.000Z", "max_issues_repo_path": "source/lambda/layers/aws-nodesdk-custom-config/test/index.spec.js", "max_issues_repo_name": "swipswaps/discovering-hot-topics-using-machine-learning", "max_issues_repo_issues_event_min_datetime": "2021-07-22T19:02:25.000Z", "max_issues_repo_issues_event_max_datetime": "2022-02-14T16:28:18.000Z", "max_forks_repo_path": "source/lambda/layers/aws-nodesdk-custom-config/test/index.spec.js", "max_forks_repo_name": "swipswaps/discovering-hot-topics-using-machine-learning", "max_forks_repo_forks_event_min_datetime": "2021-09-28T03:09:08.000Z", "max_forks_repo_forks_event_max_datetime": "2022-02-24T16:33:25.000Z"}
{"max_stars_count": 8, "max_issues_count": 21, "max_forks_count": 7, "avg_line_length": 56.6, "max_line_length": 119, "alphanum_fraction": 0.4085689046}
/**********************************************************************************************************************
 *  Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.                                                *
 *                                                                                                                    *
 *  Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance    *
 *  with the License. A copy of the License is located at                                                             *
 *                                                                                                                    *
 *      http://www.apache.org/licenses/LICENSE-2.0                                                                    *
 *                                                                                                                    *
 *  or in the 'license' file accompanying this file. This file is distributed on an 'AS IS' BASIS, WITHOUT WARRANTIES *
 *  OR CONDITIONS OF ANY KIND, express or implied. See the License for the specific language governing permissions    *
 *  and limitations under the License.                                                                                *
 *********************************************************************************************************************/

"use strict"

const sinon = require('sinon');
const assert = require('assert');
const layerFunction = require('../index');

describe('calling aws-nodesdk-custom-config', () => {
    beforeEach(() => {
        process.env.AWS_SDK_USER_AGENT = '{ "cutomerAgent": "fakedata" }'
        process.env.AWS_REGION = 'us-east-1'
    });

    it('should return a json config', async () => {
        const layerFuncSpy = sinon.spy(layerFunction, 'customAwsConfig');
        assert(layerFunction.customAwsConfig(), {
            ...JSON.parse(process.env.AWS_SDK_USER_AGENT),
            region: process.env.AWS_REGION,
            maxRetries: 10,
        });
        sinon.assert.calledOnce(layerFuncSpy);
    });

    afterEach(() => {
        delete process.env.AWS_SDK_USER_AGENT;
        delete process.env.AWS_REGION;
    });
});