<commit_before>import React from 'react';
import { mount } from 'enzyme';
import fetchMock from 'fetch-mock';
import './helpers/mockAsyncRequest';
import './helpers/miqSparkle';

import ReportDataTable from '../components/report-data-table';

describe('<ReportDataTable />', () => {
  let initialProps;

  beforeEach(() => {
    initialProps = {
      reportResultId: 123,
    };
  });

  afterEach(() => {
    fetchMock.reset();
  });

  it('should fetch report data when instantiated', (done) => {
    const sortBy = '';
    const sortDirection = '';
    const limit = 20;
    const offset = 0;
    const url = `/api/results/${initialProps.reportResultId}?\
hash_attribute=result_set&\
sort_by=${sortBy}&sort_order=${sortDirection}&\
limit=${limit}&offset=${offset}`;

    fetchMock.getOnce(url, { report: { col_order: [] }, count: 0, result_set: [] });

    const wrapper = mount(<ReportDataTable {...initialProps} />);

    setTimeout(() => {
      expect(fetchMock.calls()).toHaveLength(1);
      expect(wrapper.find('div.table-view-pf-toolbar')).toHaveLength(1);
      expect(wrapper.find('table.table')).toHaveLength(1);
      expect(wrapper.find('form.table-view-pf-pagination')).toHaveLength(1);
      done();
    });
  });
});<commit_msg>Report results: test: add act()<commit_after>import React from 'react';
import { mount } from 'enzyme';
import fetchMock from 'fetch-mock';
import { act } from 'react-test-renderer';

import './helpers/mockAsyncRequest';
import './helpers/miqSparkle';

import ReportDataTable from '../components/report-data-table';

describe('<ReportDataTable />', () => {
  let initialProps;

  beforeEach(() => {
    initialProps = {
      reportResultId: 123,
    };
  });

  afterEach(() => {
    fetchMock.reset();
  });

  it('should fetch report data when instantiated', (done) => {
    const sortBy = '';
    const sortDirection = '';
    const limit = 20;
    const offset = 0;
    const url = `/api/results/${initialProps.reportResultId}?\
hash_attribute=result_set&\
sort_by=${sortBy}&sort_order=${sortDirection}&\
limit=${limit}&offset=${offset}`;

    fetchMock.getOnce(url, { report: { col_order: [] }, count: 0, result_set: [] });

    let wrapper;

    act(() => {
      wrapper = mount(<ReportDataTable {...initialProps} />);
    });

    setTimeout(() => {
      expect(fetchMock.calls()).toHaveLength(1);
      expect(wrapper.find('div.table-view-pf-toolbar')).toHaveLength(1);
      expect(wrapper.find('table.table')).toHaveLength(1);
      expect(wrapper.find('form.table-view-pf-pagination')).toHaveLength(1);
      done();
    });
  });
});
{'fraction_non_alphanumeric': 0.18836671802773497, 'fraction_numerical': 0.00847457627118644, 'mean_word_length': 3.791512915129151, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 18, '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': '2130999', 'n_tokens_mistral': 826, 'n_tokens_neox': 805, 'n_words': 146}