<commit_before>import AsyncLoadErrors from '../../../src/components/error-monitoring/async-load-error';
import { SnapShot } from '../helpers/component-testing';
import { isReloaded, reloadOnce, forceReload } from '../../../src/helpers/reload';
jest.mock('../../../src/helpers/reload');

describe('AsyncLoadErrors Component', function() {
  let props;
  beforeEach(() => {
    props = { error: new Error('SOMETHING FAILED!') };
  });

  it('does not render if page isnt reloaded', () => {
    const err = mount(<AsyncLoadErrors {...props} />);
    expect(reloadOnce).toHaveBeenCalled();
    expect(err.html()).toBeNull();
  });

  it('renders and matches snapshot if page is reloaded', () => {
    isReloaded.mockImplementation(() => true);
    const err = mount(<AsyncLoadErrors {...props} />);
    expect(err.html()).not.toBeNull();
    expect(SnapShot.create(<AsyncLoadErrors {...props} />)).toMatchSnapshot();
  });

  it('forces a reload when clicked', () => {
    isReloaded.mockImplementation(() => true);
    const err = mount(<AsyncLoadErrors {...props} />);
    err.find('Button').simulate('click');
    expect(forceReload).toHaveBeenCalled();
  });

});
<commit_msg>reload once should no longer be called<commit_after>import AsyncLoadErrors from '../../../src/components/error-monitoring/async-load-error';
import { SnapShot } from '../helpers/component-testing';
import { isReloaded, reloadOnce, forceReload } from '../../../src/helpers/reload';
jest.mock('../../../src/helpers/reload');

describe('AsyncLoadErrors Component', function() {
  let props;
  beforeEach(() => {
    props = { error: new Error('SOMETHING FAILED!') };
  });

  it('does not render if page isnt reloaded', () => {
    const err = mount(<AsyncLoadErrors {...props} />);
    expect(reloadOnce).not.toHaveBeenCalled();
    expect(err.html()).toBeNull();
  });

  it('renders and matches snapshot if page is reloaded', () => {
    isReloaded.mockImplementation(() => true);
    const err = mount(<AsyncLoadErrors {...props} />);
    expect(err.html()).not.toBeNull();
    expect(SnapShot.create(<AsyncLoadErrors {...props} />)).toMatchSnapshot();
  });

  it('forces a reload when clicked', () => {
    isReloaded.mockImplementation(() => true);
    const err = mount(<AsyncLoadErrors {...props} />);
    err.find('Button').simulate('click');
    expect(forceReload).toHaveBeenCalled();
  });

});

{'fraction_non_alphanumeric': 0.20453590928181437, 'fraction_numerical': 0.0, 'mean_word_length': 3.783132530120482, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 23, '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': '1115667', 'n_tokens_mistral': 737, 'n_tokens_neox': 724, 'n_words': 146}