<commit_before><commit_msg>Add tests for config function<commit_after>import Middleware, { SetupExecutor, ResultsExecutor } from "./types/Middleware";
import Setup from "./types/Setup";
import config from "./config";

describe("config", () => {
  let middlewares: Array<Middleware>;
  let middlewareASetupExector: SetupExecutor;
  let middlewareAResultsExector: ResultsExecutor;
  let middlewareBSetupExector: SetupExecutor;
  let middlewareBResultsExector: ResultsExecutor;

  beforeEach(() => {
    middlewareAResultsExector = jest.fn();
    middlewareASetupExector = jest.fn(
      (setup: Setup) => middlewareAResultsExector
    );

    middlewareBResultsExector = jest.fn();
    middlewareBSetupExector = jest.fn(
      (setup: Setup) => middlewareBResultsExector
    );

    middlewares = [middlewareASetupExector, middlewareBSetupExector];
  });

  it("should not call middleware", () => {
    config(...middlewares);

    expect(middlewareASetupExector).not.toHaveBeenCalled();
    expect(middlewareAResultsExector).not.toHaveBeenCalled();
    expect(middlewareBSetupExector).not.toHaveBeenCalled();
    expect(middlewareBResultsExector).not.toHaveBeenCalled();
  });

  describe("returned function", () => {
    it("should call middleware", () => {
      config(...middlewares)();

      expect(middlewareASetupExector).toHaveBeenCalled();
      expect(middlewareAResultsExector).toHaveBeenCalled();
      expect(middlewareBSetupExector).toHaveBeenCalled();
      expect(middlewareBResultsExector).toHaveBeenCalled();
    });
  });
});
{'fraction_non_alphanumeric': 0.12759067357512954, 'fraction_numerical': 0.0, 'mean_word_length': 4.9652509652509655, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 11, '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': '1503491', 'n_tokens_mistral': 462, 'n_tokens_neox': 468, 'n_words': 71}