Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,42 @@
import React from 'react';
import { render } from '@testing-library/react';
import { render, screen } from '@testing-library/react';
import { Backdrop } from '../Backdrop';

test('Backdrop Test', () => {
test('Renders without children', () => {
render(
<div data-testid="backdrop">
<Backdrop />
</div>
);
expect(screen.getByTestId('backdrop').firstChild).toBeVisible();
});

test('Renders children', () => {
render(<Backdrop>Test</Backdrop>);
expect(screen.getByText('Test')).toBeVisible();
});

test('Renders with the pf-c-backdrop', () => {
render(<Backdrop>Test</Backdrop>);
expect(screen.getByText('Test')).toHaveClass('pf-c-backdrop');
});

test('Renders with only the class pf-c-backdrop by default', () => {
render(<Backdrop>Test</Backdrop>);
expect(screen.getByText('Test')).toHaveClass('pf-c-backdrop', { exact: true });
});

test('Renders with custom class name when className prop is passed', () => {
render(<Backdrop className="test-class">Test</Backdrop>);
expect(screen.getByText('Test')).toHaveClass('test-class');
});

test('Renders with the inherited element props spread to the component', () => {
render(<Backdrop aria-label="this is a simple backdrop">Test</Backdrop>);
expect(screen.getByText('Test')).toHaveAccessibleName('this is a simple backdrop');
});

test('Matches the snapshot', () => {
const { asFragment } = render(<Backdrop>Backdrop</Backdrop>);
expect(asFragment()).toMatchSnapshot();
});
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Backdrop Test 1`] = `
exports[`Matches the snapshot 1`] = `
<DocumentFragment>
<div
class="pf-c-backdrop"
Expand Down