<commit_before>import { beforeEach } from '@bigtest/mocha';
import { setupAppForTesting, visit, location } from '@bigtest/react';
import localforage from 'localforage';
import sinon from 'sinon';

// load these styles for our tests
import 'typeface-source-sans-pro';
import '@folio/stripes-components/lib/global.css';

import startMirage from '../network/start';

import App from '../../../src/App';
import * as actions from '../../../src/okapiActions';

import {
  withModules,
  clearModules,
  withConfig,
  clearConfig
} from './stripes-config';

export default function setupApplication({
  disableAuth = true,
  modules = [],
  translations = {},
  permissions = {},
  stripesConfig,
  mirageOptions,
  scenarios
} = {}) {
  beforeEach(async function () {
    const initialState = {};

    // when auth is disabled, add a fake user to the store
    if (disableAuth) {
      initialState.okapi = {
        token: 'test',
        currentUser: {
          id: 'test',
          username: 'testuser',
          firstName: 'Test',
          lastName: 'User',
          email: '<EMAIL>',
          addresses: [],
          servicePoints: []
        },
        currentPerms: permissions
      };
    }

    // mount the app
    this.app = await setupAppForTesting(App, {
      mountId: 'testing-root',

      props: {
        initialState
      },

      setup: () => {
        this.server = startMirage(scenarios, mirageOptions);
        this.server.logging = false;

        withModules(modules);
        withConfig({ logCategories: '', ...stripesConfig });

        sinon.stub(actions, 'setTranslations').callsFake(incoming => {
          return {
            type: 'SET_TRANSLATIONS',
            translations: Object.assign(incoming, translations)
          };
        });
      },

      teardown: () => {
        actions.setTranslations.restore();
        clearConfig();
        clearModules();
        localforage.clear();
        this.server.shutdown();<commit_msg>Remove sinon from test helper to prevent args being retained<commit_after>import { beforeEach } from '@bigtest/mocha';
import { setupAppForTesting, visit, location } from '@bigtest/react';
import localforage from 'localforage';

// load these styles for our tests
import 'typeface-source-sans-pro';
import '@folio/stripes-components/lib/global.css';

import startMirage from '../network/start';

import App from '../../../src/App';
import * as actions from '../../../src/okapiActions';

import {
  withModules,
  clearModules,
  withConfig,
  clearConfig
} from './stripes-config';

const { assign } = Object;

export default function setupApplication({
  disableAuth = true,
  modules = [],
  translations = {},
  permissions = {},
  stripesConfig,
  mirageOptions,
  scenarios
} = {}) {
  beforeEach(async function () {
    const initialState = {};

    // when auth is disabled, add a fake user to the store
    if (disableAuth) {
      initialState.okapi = {
        token: 'test',
        currentUser: {
          id: 'test',
          username: 'testuser',
          firstName: 'Test',
          lastName: 'User',
          email: '<EMAIL>',
          addresses: [],
          servicePoints: []
        },
        currentPerms: permissions
      };
    }

    // mount the app
    this.app = await setupAppForTesting(App, {
      mountId: 'testing-root',

      props: {
        initialState
      },

      setup: () => {
        this.server = startMirage(scenarios, mirageOptions);
        this.server.logging = false;

        withModules(modules);
        withConfig({ logCategories: '', ...stripesConfig });

        assign(actions, {
          _setTranslations: null,
          setTranslations: incoming => {
            return {
              type: 'SET_TRANSLATIONS',
              translations: assign(incoming, translations)
            };
          }
        });
      },

      teardown: () => {
        assign(actions, {
          setTranslations: actions._setTranslations,
          _setTranslations: null
        });

        clearConfig();
        clearModules();
        localforage.clear();
        this.server.shutdown();
        this.server = null;
        this.app = null;
{'fraction_non_alphanumeric': 0.1318312559923298, 'fraction_numerical': 0.0, 'mean_word_length': 2.222393822393822, 'pattern_counts': {'":': 0, '<': 5, '<?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': '7237420', 'n_tokens_mistral': 1180, 'n_tokens_neox': 1182, 'n_words': 276}