UNPKG

rsuite

Version:

A suite of react components

31 lines (25 loc) 1.18 kB
import React from 'react'; import { findDOMNode } from 'react-dom'; import ReactTestUtils from 'react-dom/test-utils'; import ModalTitle from '../ModalTitle'; describe('ModalTitle', () => { it('Should render a modal title', () => { const title = 'Test'; const instance = ReactTestUtils.renderIntoDocument(<ModalTitle>{title}</ModalTitle>); assert.equal(findDOMNode(instance).className, 'rs-modal-title'); assert.equal(findDOMNode(instance).innerHTML, title); }); it('Should have a custom className', () => { const instance = ReactTestUtils.renderIntoDocument(<ModalTitle className="custom" />); assert.ok(findDOMNode(instance).className.match(/\bcustom\b/)); }); it('Should have a custom style', () => { const fontSize = '12px'; const instance = ReactTestUtils.renderIntoDocument(<ModalTitle style={{ fontSize }} />); assert.equal(findDOMNode(instance).style.fontSize, fontSize); }); it('Should have a custom className prefix', () => { const instance = ReactTestUtils.renderIntoDocument(<ModalTitle classPrefix="custom-prefix" />); assert.ok(findDOMNode(instance).className.match(/\bcustom-prefix\b/)); }); });