Skip to content

Commit

Permalink
Added initial Th test file
Browse files Browse the repository at this point in the history
  • Loading branch information
thatblindgeye committed Mar 11, 2024
1 parent ad65286 commit 44b37d6
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions packages/react-table/src/components/Table/__tests__/Th.test.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import * as React from 'react';
import { render, screen } from '@testing-library/react';
import { Th } from '../Th';

test('Does not render with aria-label by default', () => {
render(<Th />);
expect(screen.getByRole('columnheader')).not.toHaveAccessibleName();
});

test('Renders with aria-label when passed in', () => {
render(<Th aria-label="Test" />);
expect(screen.getByRole('columnheader')).toHaveAccessibleName('Test');
});

test('Does not render with screen reader text by default', () => {
render(<Th />);

expect(screen.getByRole('columnheader')).toBeEmptyDOMElement();
});

test('Does not render with screen reader text when children are passed in', () => {
render(<Th screenReaderText="Test">Heading label</Th>);

expect(screen.getByRole('columnheader')).not.toHaveTextContent('Test');
});

test('Renders with screen reader text when screenReaderText is passed in', () => {
render(<Th screenReaderText="Test" />);

expect(screen.getByRole('columnheader')).toHaveTextContent('Test');
});

0 comments on commit 44b37d6

Please sign in to comment.