<commit_before>import React from 'react';
import assert from 'assert';
import { shallow } from 'enzyme';
import sinon from 'sinon';
import WorkflowsTable from './workflows-table';

const meta = function () {
  return { meta: { page: 1, page_size: 1 }};
};

const workflows = [
  { active: true, id: '1', display_name: 'Rad Workflow', getMeta: meta },
  { active: true, id: '2', display_name: 'Cool Workflow', getMeta: meta }
];

const project = {
  configuration: {}
};

describe('WorkflowsPage', function () {
  let wrapper;

  const workflowStatusChangeSpy = sinon.spy();

  before(function () {
    wrapper = shallow(
      <WorkflowsTable
        labPath={(url) => { return url; }}
        project={project}
        changeStatus={workflowStatusChangeSpy}
        workflows={workflows}
      />
    );
    wrapper.setProps({ loading: false });
  });

  it('will display the correct amount of workflows', function () {
    assert.equal(wrapper.find('Link').length, 2);
  });
});<commit_msg>Finish tests<commit_after>import React from 'react';
import assert from 'assert';
import { shallow } from 'enzyme';
import { expect } from 'chai';
import sinon from 'sinon';
import WorkflowsTable from './workflows-table';

const meta = function () {
  return { meta: { page: 1, page_size: 1 }};
};

const workflows = [
  { active: false, id: '1', display_name: 'Rad Workflow', getMeta: meta },
  { active: true, id: '2', display_name: 'Cool Workflow', getMeta: meta }
];

const project = {
  configuration: {}
};

describe('WorkflowsTable', function () {
  let wrapper;
  const statusChangeSpy = sinon.spy();
  const statsVisibilityChangeSpy = sinon.spy();
  const completenessTypeChangeSpy = sinon.spy();

  before(function () {
    wrapper = shallow(
      <WorkflowsTable
        labPath={(url) => { return url; }}
        project={project}
        handleSetStatsCompletenessType={completenessTypeChangeSpy}
        handleWorkflowStatsVisibility={statsVisibilityChangeSpy}
        handleWorkflowStatusChange={statusChangeSpy}
        meta={meta}
        workflows={workflows}
      />
    );
  });

  it('should display the correct amount of workflows', function () {
    expect(wrapper.find('Link')).to.have.lengthOf(2);
  });

  it('should call handleWorkflowStatusChange on status checkbox change', function () {
    const statusCheckbox = wrapper.find('input[id="active"]').at(0);
    statusCheckbox.simulate('change');
    expect(statusChangeSpy.calledOnce).to.be.true;
  });

  it('should call handleSetStatsCompletenessType on completeness-type-classification change', function () {
    const completenessRadioButton = wrapper.find('input[value="classification"]').at(0);
    completenessRadioButton.simulate('change');
    expect(completenessTypeChangeSpy.calledOnce).to.be.true;
    completenessTypeChangeSpy.reset();
  });

  it('should call handleSetStatsCompletenessType on completeness-type-retirement change', function () {
    const completenessRadioButton = wrapper.find('input[value="retirement"]').at(1);
    completenessRadioButton.simulate('change');
    expect(completenessTypeChangeSpy.calledOnce).to.be.true;
  });

  it('should call handleWorkflowStatsVisibility on visibility checkbox change', function () {
    const statsVisibilityCheckbox = wrapper.find({name: `stats_visible.${workflows[0].id}`}).at(0);
    statsVisibilityCheckbox.simulate('change');
    expect(statsVisibilityChangeSpy.calledOnce).to.be.true;
  });
});
{'fraction_non_alphanumeric': 0.14223512336719885, 'fraction_numerical': 0.0043541364296081275, 'mean_word_length': 4.367601246105919, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, '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': '1770432', 'n_tokens_mistral': 1061, 'n_tokens_neox': 1027, 'n_words': 226}