<commit_before>import React from 'react';
import { shallow } from 'enzyme';
import { EditorState } from 'draft-js';

import Toolbar from '../components/Toolbar';

const mockProps = {
    editorState: EditorState.createEmpty(),
    enableHorizontalRule: false,
    enableLineBreak: false,
    showUndoRedoControls: false,
    entityTypes: [],
    blockTypes: [],
    inlineStyles: [],
    toggleBlockType: () => {},
    toggleInlineStyle: () => {},
    addHR: () => {},
    addBR: () => {},
    onUndoRedo: () => {},
    onRequestDialog: () => {},
};

describe('Toolbar', () => {
    it('exists', () => {
        expect(Toolbar).toBeDefined();
    });

    it('empty', () => {
        expect(shallow(<Toolbar {...mockProps} />)).toMatchSnapshot();
    });

    it('#enableHorizontalRule', () => {
        expect(
            shallow(<Toolbar {...mockProps} enableHorizontalRule={true} />),
        ).toMatchSnapshot();
    });

    it('#enableLineBreak', () => {
        expect(
            shallow(<Toolbar {...mockProps} enableLineBreak={true} />),
        ).toMatchSnapshot();
    });

    it('#showUndoRedoControls', () => {
        expect(
            shallow(<Toolbar {...mockProps} showUndoRedoControls={true} />),
        ).toMatchSnapshot();
    });

    it('#entityTypes', () => {
        expect(
            shallow(
                <Toolbar
                    {...mockProps}
                    entityTypes={[
                        { type: 'TEST_1', label: 'Test 1' },
                        {
                            type: 'TEST_2',
                            label: 'Test 2',
                            icon: 'icon-test-2',
                        },
                        {
                            type: 'TEST_3',
                            label: 'Test 3',
                            icon: 'icon-test-3',
                        },
                    ]}
                />,
            ),
        ).toMatchSnapshot();
    });

    it('#blockTypes', () => {
        expect(
            shallow(
                <Toolbar
                    {...mockProps}
                    blockTypes={[
                        { type: 'TEST_1', label: 'Test 1' },
                        {
                            type: 'TEST_2',
                            label: 'Test 2',
                            icon: 'icon-test-2',
                        },
                        {
                            type: 'TEST_3',
                            label: 'Test 3',
                            icon: 'icon-test-3',
                        },
                    ]}
                />,
            ),
        ).toMatchSnapshot();
    });

    it('#inlineStyles', () => {
        expect(
            shallow(
                <Toolbar
                    {...mockProps}
                    inlineStyles={[
                        { type: 'TEST_1', label: 'Test 1' },
                        {
                            type: 'TEST_2',
                            label: 'Test 2',
                            icon: 'icon-test-2',
                        },
                        {
                            type: 'TEST_3',
                            label: 'Test 3',
                            icon: 'icon-test-3',
                        },
                    ]}
                />,
            ),
        ).toMatchSnapshot();
    });
});<commit_msg>Add missing tests for toolbar button title<commit_after>import React from 'react';
import { shallow } from 'enzyme';
import { EditorState } from 'draft-js';

import Toolbar from '../components/Toolbar';

const mockProps = {
    editorState: EditorState.createEmpty(),
    enableHorizontalRule: false,
    enableLineBreak: false,
    showUndoRedoControls: false,
    entityTypes: [],
    blockTypes: [],
    inlineStyles: [],
    toggleBlockType: () => {},
    toggleInlineStyle: () => {},
    addHR: () => {},
    addBR: () => {},
    onUndoRedo: () => {},
    onRequestDialog: () => {},
};

describe('Toolbar', () => {
    it('exists', () => {
        expect(Toolbar).toBeDefined();
    });

    it('empty', () => {
        expect(shallow(<Toolbar {...mockProps} />)).toMatchSnapshot();
    });

    it('#enableHorizontalRule', () => {
        expect(
            shallow(<Toolbar {...mockProps} enableHorizontalRule={true} />),
        ).toMatchSnapshot();
    });

    it('#enableLineBreak', () => {
        expect(
            shallow(<Toolbar {...mockProps} enableLineBreak={true} />),
        ).toMatchSnapshot();
    });

    it('#showUndoRedoControls', () => {
        expect(
            shallow(<Toolbar {...mockProps} showUndoRedoControls={true} />),
        ).toMatchSnapshot();
    });

    it('#entityTypes', () => {
        expect(
            shallow(
                <Toolbar
                    {...mockProps}
                    entityTypes={[
                        { type: 'TEST_1', label: 'Test 1' },
                        {
                            type: 'TEST_2',
                            label: 'Test 2',
                            icon: 'icon-test-2',
                        },
                        {
                            type: 'TEST_3',
                            label: 'Test 3',
                            icon: 'icon-test-3',
                        },
                    ]}
                />,
            ),
        ).toMatchSnapshot();
    });

    it('#blockTypes', () => {
        expect(
            shallow(
                <Toolbar
                    {...mockProps}
                    blockTypes={[
                        { type: 'TEST_1', label: 'Test 1' },
                        {
                            type: 'TEST_2',
                            label: 'Test 2',
                            icon: 'icon-test-2',
                        },
                        {
                            type: 'TEST_3',
                            label: 'Test 3',
                            icon: 'icon-test-3',
                        },
                    ]}
                />,
            ),
        ).toMatchSnapshot();
    });

    it('#inlineStyles', () => {
        expect(
            shallow(
                <Toolbar
                    {...mockProps}
                    inlineStyles={[
                        { type: 'TEST_1', label: 'Test 1' },
                        {
                            type: 'TEST_2',
                            label: 'Test 2',
                            icon: 'icon-test-2',
                        },
                        {
                            type: 'TEST_3',
                            label: 'Test 3',
                            icon: 'icon-test-3',
                        },
                    ]}
                />,
            ),
        ).toMatchSnapshot();
    });

    it('button titles with shortcut', () => {
        expect(
            shallow(
                <Toolbar
                    {...mockProps}
                    inlineStyles={[
                        {
                            type: 'BOLD',
                            icon: 'icon-bold',
                        },
                    ]}
                />,
            )
                .find('ToolbarButton')
                .prop('title'),
        ).toBe('(Ctrl+B)');
    });

    it('button titles with shortcut and description', () => {
        expect(
            shallow(
                <Toolbar
                    {...mockProps}
                    inlineStyles={[
                        {
                            type: 'BOLD',
                            description: 'Bold',
                            icon: 'icon-bold',
                        },
                    ]}
                />,
            )
                .find('ToolbarButton')
                .prop('title'),
        ).toBe('Bold (Ctrl+B)');
    });
});
{'fraction_non_alphanumeric': 0.1430578617958871, 'fraction_numerical': 0.006131051219823732, 'mean_word_length': 0.8633983817229891, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 51, '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': '1530631', 'n_tokens_mistral': 1961, 'n_tokens_neox': 1873, 'n_words': 319}