<commit_before>'use strict';

const path = require('path');
const { getFunctionOptions } = require('../../functionHelper');

describe('functionHelper', () => {
  describe('#getFunctionOptions', () => {
    const funName = 'testFunction';
    const servicePath = 'src';

    let result;
    beforeEach(() => {
      const fun = {
        handler: 'handler.hello',
      };
      result = getFunctionOptions(fun, funName, servicePath);
    });

    test('should have the correct funName', () => {
      expect(result.funName).toEqual(funName);
    });

    test('should have the correct handler name', () => {
      expect(result.handlerName).toEqual('hello');
    });

    test('should have the correct handler path', () => {
      expect(result.handlerPath).toEqual(path.join('src', 'handler'));
    });

    test('should have the default timeout', () => {
      expect(result.funTimeout).toEqual(30000);
    });

    test('should have babelOptions undefined', () => {
      expect(result.babelOptions).toEqual(undefined);
    });

    test('nested folders for handlers', () => {
      const fun = {
        handler: './somefolder/.handlers/handler.run',
      };
      const result = getFunctionOptions(fun, funName, servicePath);
      expect(result.handlerName).toEqual('run');
      expect(result.handlerPath).toEqual(
        path.join('src', 'somefolder', '.handlers', 'handler'),
      );
    });

    describe('with a timeout', () => {
      beforeEach(() => {
        const fun = {
          handler: 'handler.hello',
          timeout: 7,
        };
        result = getFunctionOptions(fun, funName, servicePath);
      });

      test('should have the correct timeout', () => {
        expect(result.funTimeout).toEqual(7000);
      });
    });
  });
});
<commit_msg>Rename variable<commit_after>'use strict';

const path = require('path');
const { getFunctionOptions } = require('../../functionHelper');

describe('functionHelper', () => {
  describe('#getFunctionOptions', () => {
    const functionName = 'testFunction';
    const servicePath = 'src';

    let result;
    beforeEach(() => {
      const functionObj = {
        handler: 'handler.hello',
      };
      result = getFunctionOptions(functionObj, functionName, servicePath);
    });

    test('should have the correct funName', () => {
      expect(result.funName).toEqual(functionName);
    });

    test('should have the correct handler name', () => {
      expect(result.handlerName).toEqual('hello');
    });

    test('should have the correct handler path', () => {
      expect(result.handlerPath).toEqual(path.join('src', 'handler'));
    });

    test('should have the default timeout', () => {
      expect(result.funTimeout).toEqual(30000);
    });

    test('should have babelOptions undefined', () => {
      expect(result.babelOptions).toEqual(undefined);
    });

    test('nested folders for handlers', () => {
      const functionObj = {
        handler: './somefolder/.handlers/handler.run',
      };
      const result = getFunctionOptions(functionObj, functionName, servicePath);
      expect(result.handlerName).toEqual('run');
      expect(result.handlerPath).toEqual(
        path.join('src', 'somefolder', '.handlers', 'handler'),
      );
    });

    describe('with a timeout', () => {
      beforeEach(() => {
        const functionObj = {
          handler: 'handler.hello',
          timeout: 7,
        };
        result = getFunctionOptions(functionObj, functionName, servicePath);
      });

      test('should have the correct timeout', () => {
        expect(result.funTimeout).toEqual(7000);
      });
    });
  });
});

{'fraction_non_alphanumeric': 0.17075185899201323, 'fraction_numerical': 0.00550812448361333, 'mean_word_length': 2.847457627118644, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 27, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3003859', 'n_tokens_mistral': 1013, 'n_tokens_neox': 990, 'n_words': 197}