<commit_before>const configReact = require('../react');
const dependencies = require('../../app/dependencies');

jest.mock('../../app/dependencies');

describe('Setup React', () => {
  test('add react dependencies', () => {
    configReact();

    expect(dependencies.add).toHaveBeenCalledWith(['react', 'react-dom']);
    expect(dependencies.addDev).toHaveBeenCalledWith(['react-test-renderer']);
  });

  test('with babel adds preset', () => {
    const baseMock = {
      babelConfig: { presets: [] },
    };

    configReact.call(baseMock, 'babel');

    expect(dependencies.addDev).toHaveBeenCalledWith(['@babel/preset-react']);
  });

  test('with babel sets the preset in babel config', () => {
    const baseMock = {
      babelConfig: { presets: [] },
    };

    configReact.call(baseMock, 'babel');

    expect(baseMock.babelConfig.presets).toStrictEqual(['@babel/preset-react']);
  });

  test('with typescript adds types', () => {
    configReact.call({}, 'typescript');

    expect(dependencies.addDev).toHaveBeenCalledWith(['@types/react', '@types/react-dom']);
  });
});<commit_msg>test: refactor spies on tests<commit_after>const configReact = require('../react');
const dependencies = require('../../app/dependencies');

describe('Setup React', () => {
  test('add react dependencies', () => {
    const spyAdd = jest.spyOn(dependencies, 'add');
    const spyAddDev = jest.spyOn(dependencies, 'addDev');

    configReact();

    expect(spyAdd).toHaveBeenCalledWith(['react', 'react-dom']);
    expect(spyAddDev).toHaveBeenCalledWith(['react-test-renderer']);

    spyAdd.mockRestore();
    spyAddDev.mockRestore();
  });

  test('with babel adds preset', () => {
    const baseMock = {
      babelConfig: { presets: [] },
    };
    const spyAddDev = jest.spyOn(dependencies, 'addDev');

    configReact.call(baseMock, 'babel');

    expect(spyAddDev).toHaveBeenCalledWith(['@babel/preset-react']);

    spyAddDev.mockRestore();
  });

  test('with babel sets the preset in babel config', () => {
    const baseMock = {
      babelConfig: { presets: [] },
    };

    configReact.call(baseMock, 'babel');

    expect(baseMock.babelConfig.presets).toStrictEqual(['@babel/preset-react']);
  });

  test('with typescript adds types', () => {
    const spyAddDev = jest.spyOn(dependencies, 'addDev');

    configReact.call({}, 'typescript');

    expect(spyAddDev).toHaveBeenCalledWith(['@types/react', '@types/react-dom']);

    spyAddDev.mockRestore();
  });
});
{'fraction_non_alphanumeric': 0.192090395480226, 'fraction_numerical': 0.0, 'mean_word_length': 4.038617886178862, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 13, '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': '1869572', 'n_tokens_mistral': 807, 'n_tokens_neox': 778, 'n_words': 123}