{"size": 1620, "ext": "js", "max_stars_repo_path": "src/modules/SharedComponents/GrantListEditor/components/GrantListEditorHeader.test.js", "max_stars_repo_name": "lifenstein/fez-frontend", "max_stars_repo_stars_event_min_datetime": "2017-06-30T00:58:59.000Z", "max_stars_repo_stars_event_max_datetime": "2021-03-23T10:42:36.000Z", "max_issues_repo_path": "src/modules/SharedComponents/GrantListEditor/components/GrantListEditorHeader.test.js", "max_issues_repo_name": "uqlibrary/fez-frontend", "max_issues_repo_issues_event_min_datetime": "2020-01-07T23:22:32.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-26T07:05:41.000Z", "max_forks_repo_path": "src/modules/SharedComponents/GrantListEditor/components/GrantListEditorHeader.test.js", "max_forks_repo_name": "lifenstein/fez-frontend", "max_forks_repo_forks_event_min_datetime": "2017-08-17T05:38:48.000Z", "max_forks_repo_forks_event_max_datetime": "2020-01-17T06:14:09.000Z"}
{"max_stars_count": 6, "max_issues_count": 14, "max_forks_count": 4, "avg_line_length": 29.4545454545, "max_line_length": 77, "alphanum_fraction": 0.587654321}
import { GrantListEditorHeader, styles } from './GrantListEditorHeader';

function setup(testProps = {}) {
    const props = {
        onDeleteAll: jest.fn(),
        locale: {},
        disabled: false,
        classes: {},
        width: '',
        hideType: false,
        ...testProps,
    };
    return getElement(GrantListEditorHeader, props);
}

describe('GrantListEditorHeader', () => {
    it('should render default view', () => {
        const wrapper = setup();
        expect(toJson(wrapper)).toMatchSnapshot();
    });

    it('should render default mobile view', () => {
        const wrapper = setup({ width: 'xs' });
        expect(toJson(wrapper)).toMatchSnapshot();
    });

    it('should hide grant agency type input', () => {
        const wrapper = setup({ hideType: true });
        expect(toJson(wrapper)).toMatchSnapshot();
    });

    it('should have a proper style generator', () => {
        expect(styles()).toMatchSnapshot();
    });

    it('should set confirmation box ref', () => {
        const wrapper = setup();
        wrapper.instance().handleConfirmationBoxRef('test');
        expect(wrapper.instance().confirmationBox).toEqual('test');
    });

    it('should show confirmation box', () => {
        const showConfirmationFn = jest.fn();
        const wrapper = setup();
        wrapper.instance().confirmationBox = {
            showConfirmation: showConfirmationFn,
        };

        expect(toJson(wrapper)).toMatchSnapshot();

        wrapper.find('WithStyles(ForwardRef(IconButton))').simulate('click');
        expect(showConfirmationFn).toHaveBeenCalled();
    });
});
