<commit_before>import * as React from "react";
import { shallow, mount, render } from "enzyme";
import { MgError } from "../../src/api/error";
import { Error } from "../../src/components/error";

function throwme() {
    throw new MgError("Uh oh!");
}

function captureError() {
    let err: any;
    try {
        throwme();
    } catch (e) {
        err = e;
    }
    return err;
}

describe("components/error", () => {
    it("renders a MgError with stack", () => {
        const err = captureError();
        const wrapper = shallow(<Error error={err} />);
        expect(wrapper.find(".bp3-callout")).toHaveLength(1);
        expect(wrapper.find(".bp3-callout .error-header")).toHaveLength(1);
        expect(wrapper.find(".bp3-callout .error-header").text()).toBe(err.message);
        expect(wrapper.find(".bp3-callout .error-stack")).toHaveLength(1);
    });
    it("renders a string without a stack", () => {
        const err = "Uh oh!";
        const wrapper = shallow(<Error error={err} />);
        expect(wrapper.find(".bp3-callout")).toHaveLength(1);
        expect(wrapper.find(".bp3-callout .error-header")).toHaveLength(1);
        expect(wrapper.find(".bp3-callout .error-header").text()).toBe(err);
        expect(wrapper.find(".bp3-callout .error-stack")).toHaveLength(0);
    });
});<commit_msg>Fix failing enzyme tests to due structural change in Error component<commit_after>import * as React from "react";
import { shallow, mount, render } from "enzyme";
import { MgError } from "../../src/api/error";
import { Error } from "../../src/components/error";

function throwme() {
    throw new MgError("Uh oh!");
}

function captureError() {
    let err: any;
    try {
        throwme();
    } catch (e) {
        err = e;
    }
    return err;
}

describe("components/error", () => {
    it("renders a MgError with stack", () => {
        const err = captureError();
        const wrapper = render(<Error error={err} />);
        expect(wrapper.find(".error-header")).toHaveLength(1);
        expect(wrapper.find(".error-header").text()).toBe(err.message);
        expect(wrapper.find(".error-stack")).toHaveLength(1);
    });
    it("renders a string without a stack", () => {
        const err = "Uh oh!";
        const wrapper = render(<Error error={err} />);
        expect(wrapper.find(".error-header")).toHaveLength(1);
        expect(wrapper.find(".error-header").text()).toBe(err);
        expect(wrapper.find(".error-stack")).toHaveLength(0);
    });
});
{'fraction_non_alphanumeric': 0.19139525532770407, 'fraction_numerical': 0.007237635705669481, 'mean_word_length': 2.9304897314375986, 'pattern_counts': {'":': 0, '<': 7, '<?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': '5262329', 'n_tokens_mistral': 771, 'n_tokens_neox': 754, 'n_words': 160}