<commit_before>jest.unmock("../../actions");
import * as React from "react";
import { AddRegimen } from "../add_button";
import { AddRegimenProps } from "../../interfaces";
import { shallow } from "enzyme";

describe("<AddRegimen/>", () => {
  function btn(props: AddRegimenProps) {
    return shallow(React.createElement(AddRegimen, props));
  }
  it("transfers class name", () => {
    expect(btn({
      className: "foo",
      dispatch: jest.fn(),
      length: 5
    }).hasClass("foo")).toBeTruthy();
  });

  it("dispatches a new regimen onclick", () => {
    let dispatch = jest.fn();
    let b = btn({ dispatch, length });
    b.find("button").simulate("click");
    expect(dispatch.mock.calls.length).toEqual(1);
    let action = dispatch.mock.calls[0][0];
    expect(action.type).toEqual("INIT_RESOURCE");
    expect(action.payload).toBeTruthy();
    expect(action.payload.kind).toEqual("regimens");<commit_msg>Fix security exception error in a test<commit_after>jest.unmock("../../actions");
let mockPush = jest.fn();
jest.mock("../../../history", () => ({ push: mockPush }));
import * as React from "react";
import { AddRegimen } from "../add_button";
import { AddRegimenProps } from "../../interfaces";
import { shallow } from "enzyme";

describe("<AddRegimen/>", () => {
  function btn(props: AddRegimenProps) {
    return shallow(<AddRegimen {...props} />);
  }
  it("transfers class name", () => {
    expect(btn({
      className: "foo",
      dispatch: jest.fn(),
      length: 5
    }).hasClass("foo")).toBeTruthy();
  });

  it("dispatches a new regimen onclick", () => {
    let dispatch = jest.fn();
    let b = btn({ dispatch, length });
    expect(mockPush.mock.calls.length).toBe(0);
    b.find("button").simulate("click");
    expect(dispatch.mock.calls.length).toEqual(1);
    let action = dispatch.mock.calls[0][0];
    expect(action.type).toEqual("INIT_RESOURCE");
    expect(action.payload).toBeTruthy();
    expect(action.payload.kind).toEqual("regimens");
{'fraction_non_alphanumeric': 0.20181177654755914, 'fraction_numerical': 0.004529441368897836, 'mean_word_length': 3.7109004739336493, 'pattern_counts': {'":': 0, '<': 6, '<?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': '5555897', 'n_tokens_mistral': 625, 'n_tokens_neox': 625, 'n_words': 126}