File size: 602 Bytes
1e92f2d |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
import React from 'react';
import { render } from 'react-testing-library';
import H1 from '../index';
describe('<H1 />', () => {
it('should render a prop', () => {
const id = 'testId';
const { container } = render(<H1 id={id} />);
expect(container.querySelector('h1').id).toEqual(id);
});
it('should render its text', () => {
const children = 'Text';
const { container, queryByText } = render(<H1>{children}</H1>);
const { childNodes } = container.querySelector('h1');
expect(childNodes).toHaveLength(1);
expect(queryByText(children)).not.toBeNull();
});
});
|