<commit_before>/* eslint no-unused-expressions:0 */

import React from 'react';
import ReactDOM from 'react-dom';
import {conformanceChecker} from '../boundless-utils-test-helpers/index';

import Modal from './index';

describe('Modal component', () => {
    const mountNode = document.body.appendChild(document.createElement('div'));
    const render = (vdom) => ReactDOM.render(vdom, mountNode);

    afterEach(() => ReactDOM.unmountComponentAtNode(mountNode));

    it('conforms to the Boundless prop interface standards', () => conformanceChecker(render, Modal, {}, '$modal'));

    it('renders .b-modal', () => {
        render(<Modal>foo</Modal>);
        expect(document.querySelector('.b-modal')).not.toBe(null);
    });

    it('renders .b-modal-mask', () => {
        render(<Modal>foo</Modal>);
        expect(document.querySelector('.b-modal-mask')).not.toBe(null);
    });

    it('renders .b-modal-wrapper', () => {
        render(<Modal>foo</Modal>);
        expect(document.querySelector('.b-modal-wrapper')).not.toBe(null);
    });

    it('accepts arbitrary HTML attributes via props.modalProps', () => {
        render(<Modal modalProps={{'data-id': 'foo'}} />);
        expect(document.querySelector('.b-modal').getAttribute('data-id')).toBe('foo');
    });

    it('accepts extra classes via props.modalProps.className', () => {
        render(<Modal modalProps={{className: 'foo'}} />);
        expect(document.querySelector('.b-modal').classList.contains('foo')).toBe(true);
    });

    it('accepts arbitrary HTML attributes via props.maskProps', () => {
        render(<Modal maskProps={{'data-id': 'foo'}} />);
        expect(document.querySelector('.b-modal-mask').getAttribute('data-id')).toBe('foo');
    });

    it('accepts extra classes via props.maskProps.className', () => {
        render(<Modal maskProps={{className: 'foo'}} />);
        expect(document.querySelector('.b-modal-mask').classList.contains('foo')).toBe(true);
    });

    it('passes down nested children to Dialog', () => {
        render(<Modal>foo</Modal>);
        expect(document.querySelector('.b-dialog').textContent).toContain('foo');
    });

    describe('passthrough to Portal', () => {
        beforeEach(() => {
            render(
                <Modal portalProps={{className: 'foo', id: 'bar', portalId: 'baz'}}>
                    bar
                </Modal>
            );
        });

        it('passes down arbitrary props', () => {
            expect(document.querySelector('[data-portal-id]').classList.contains('foo')).toBe(true);
            expect(document.querySelector('#bar[data-portal-id]')).not.toBeNull();
            expect(document.querySelector('[data-portal-id="baz"]')).not.toBeNull();
        });
    });
});<commit_msg>Modal test cleanup, no prop changes<commit_after>/* eslint no-unused-expressions:0 */

import React from 'react';
import ReactDOM from 'react-dom';
import {$, conformanceChecker} from '../boundless-utils-test-helpers/index';

import Modal from './index';

describe('Modal component', () => {
    const mountNode = document.body.appendChild(document.createElement('div'));
    const render = (vdom) => ReactDOM.render(vdom, mountNode);

    afterEach(() => ReactDOM.unmountComponentAtNode(mountNode));

    it('conforms to the Boundless prop interface standards', () => conformanceChecker(render, Modal, {}, '$modal'));

    it('renders .b-modal', () => {
        render(<Modal>foo</Modal>);
        expect($('.b-modal')).not.toBe(null);
    });

    it('renders .b-modal-mask', () => {
        render(<Modal>foo</Modal>);
        expect($('.b-modal-mask')).not.toBe(null);
    });

    it('renders .b-modal-wrapper', () => {
        render(<Modal>foo</Modal>);
        expect($('.b-modal-wrapper')).not.toBe(null);
    });

    it('accepts arbitrary HTML attributes via props.modalProps', () => {
        render(<Modal modalProps={{'data-id': 'foo'}} />);
        expect($('.b-modal').getAttribute('data-id')).toBe('foo');
    });

    it('accepts extra classes via props.modalProps.className', () => {
        render(<Modal modalProps={{className: 'foo'}} />);
        expect($('.b-modal').classList.contains('foo')).toBe(true);
    });

    it('accepts arbitrary HTML attributes via props.maskProps', () => {
        render(<Modal maskProps={{'data-id': 'foo'}} />);
        expect($('.b-modal-mask').getAttribute('data-id')).toBe('foo');
    });

    it('accepts extra classes via props.maskProps.className', () => {
        render(<Modal maskProps={{className: 'foo'}} />);
        expect($('.b-modal-mask').classList.contains('foo')).toBe(true);
    });

    it('passes down nested children to Dialog', () => {
        render(<Modal>foo</Modal>);
        expect($('.b-dialog').textContent).toContain('foo');
    });

    describe('passthrough to Portal', () => {
        beforeEach(() => {
            render(
                <Modal portalProps={{className: 'foo', id: 'bar', portalId: 'baz'}}>
                    bar
                </Modal>
            );
        });

        it('passes down arbitrary props', () => {
            expect($('[data-portal-id]').classList.contains('foo')).toBe(true);
            expect($('#bar[data-portal-id]')).not.toBeNull();
            expect($('[data-portal-id="baz"]')).not.toBeNull();
        });
    });
});
{'fraction_non_alphanumeric': 0.21004136893569011, 'fraction_numerical': 0.000376081233546446, 'mean_word_length': 3.0295454545454548, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 61, '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': '6068267', 'n_tokens_mistral': 1555, 'n_tokens_neox': 1565, 'n_words': 245}