<commit_before>define(['common/events', 'common/ui', 'common/html', 'widgets/appWidgets2/common', 'testUtil'], (
    Events,
    UI,
    html,
    WidgetCommon,
    TestUtil
) => {
    'use strict';
    const div = html.tag('div'),
        button = html.tag('button');

    describe('Test WidgetCommon module', () => {
        let container;
        beforeEach(function () {
            container = document.createElement('div');
            this.events = Events.make({ node: container });
            this.ui = UI.make({ node: container });
        });
        afterEach(() => {
            container.remove();
            TestUtil.clearRuntime();
        });

        it('Should be loaded with the right functions', () => {
            expect(WidgetCommon).toBeDefined();
            expect(WidgetCommon.clipboardButton).toBeDefined();
            expect(WidgetCommon.containerContent).toBeDefined();
        });

        it('Should be able to produce content with a clipboard icon', function () {
            const input = document.createElement('div');
            container.innerHTML = WidgetCommon.containerContent(
                div,
                button,
                this.events,
                this.ui,
                container,
                input
            );
            expect(container.querySelector('[data-element=icon]')).toHaveClass('fa-clipboard');
        });

        it('Should be able to create the clipboard icon', function () {
            container.innerHTML = WidgetCommon.clipboardButton(
                div,
                button,
                this.events,
                this.ui,
                container
            );
            expect(container.querySelector('[data-element=icon]')).toHaveClass('fa-clipboard');
        });
    });
});<commit_msg>add more clipboard button tests. again.<commit_after>define(['common/events', 'common/ui', 'common/html', 'widgets/appWidgets2/common', 'testUtil'], (
    Events,
    UI,
    html,
    WidgetCommon,
    TestUtil
) => {
    'use strict';
    const div = html.tag('div'),
        button = html.tag('button');

    describe('Test WidgetCommon module', () => {
        beforeEach(function () {
            this.container = document.createElement('div');
            document.body.appendChild(this.container);
            this.events = Events.make({ node: this.container });
            this.ui = UI.make({ node: this.container });
        });
        afterEach(function () {
            this.container.remove();
            TestUtil.clearRuntime();
        });

        it('Should be loaded with the right functions', () => {
            expect(WidgetCommon).toBeDefined();
            expect(WidgetCommon.clipboardButton).toBeDefined();
            expect(WidgetCommon.containerContent).toBeDefined();
        });

        it('Should be able to produce content with a clipboard icon', function () {
            const input = document.createElement('div');
            this.container.innerHTML = WidgetCommon.containerContent(
                div,
                button,
                this.events,
                this.ui,
                this.container,
                input
            );
            expect(this.container.querySelector('[data-element=icon]')).toHaveClass('fa-clipboard');
        });

        it('Should be able to create the clipboard icon', function () {
            this.container.innerHTML = WidgetCommon.clipboardButton(
                div,
                button,
                this.events,
                this.ui,
                this.container
            );
            expect(this.container.querySelector('[data-element=icon]')).toHaveClass('fa-clipboard');
        });

        it('Should copy input to the clipboard with a click', function () {
            const text = 'some text';
            const contrivedInput = div(
                {
                    role: 'textbox',
                },
                text
            );
            this.container.innerHTML = WidgetCommon.containerContent(
                div,
                button,
                this.events,
                this.ui,
                this.container,
                contrivedInput
            );
            this.events.attachEvents(this.container);
            const btn = this.container.querySelector('button');
            spyOn(navigator.clipboard, 'writeText');
            btn.click();
            expect(navigator.clipboard.writeText).toHaveBeenCalledWith(text);
        });

        it('Should copy callback-specified input to the clipboard with a click', function () {
            const otherText = 'something completely different.';
            const contrivedInput = div();
            this.container.innerHTML = WidgetCommon.containerContent(
                div,
                button,
                this.events,
                this.ui,
                this.container,
                contrivedInput,
                () => otherText
            );
            this.events.attachEvents(this.container);
            const btn = this.container.querySelector('button');
            spyOn(navigator.clipboard, 'writeText');
            btn.click();
            expect(navigator.clipboard.writeText).toHaveBeenCalledWith(otherText);
        });
    });
});
{'fraction_non_alphanumeric': 0.12008320726172465, 'fraction_numerical': 0.00037821482602118004, 'mean_word_length': 1.6591251885369533, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 11, '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': '3818616', 'n_tokens_mistral': 1288, 'n_tokens_neox': 1257, 'n_words': 248}