Skip to content

Commit

Permalink
refactor(react): update table container tests to use testing-library
Browse files Browse the repository at this point in the history
  • Loading branch information
joshblack committed May 31, 2022
1 parent f045df0 commit 0591bf3
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 29 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,30 @@
* LICENSE file in the root directory of this source tree.
*/

import { render } from '@testing-library/react';
import React from 'react';
import { mount } from 'enzyme';
import { TableContainer } from '../';

describe('DataTable.TableContainer', () => {
it('should render', () => {
const wrapper = mount(<TableContainer className="custom-class" />);
expect(wrapper).toMatchSnapshot();
describe('TableContainer', () => {
it('should set the max-width class if stickyHeader is true', () => {
const { container } = render(<TableContainer stickyHeader />);
expect(container.firstChild).toHaveClass('cds--data-table--max-width');
});

it('should support enable sticky header', () => {
const wrapper = mount(<TableContainer stickyHeader={true} />);
expect(wrapper).toMatchSnapshot();
it('should set the static class if useStaticWidth is true', () => {
const { container } = render(<TableContainer useStaticWidth />);
expect(container.firstChild).toHaveClass(
'cds--data-table-container--static'
);
});

it('should support a custom className on the outermost element', () => {
const { container } = render(<TableContainer className="custom-class" />);
expect(container.firstChild).toHaveClass('custom-class');
});

it('should spread props onto the <table> element', () => {
const { container } = render(<TableContainer data-testid="test" />);
expect(container.firstChild).toHaveAttribute('data-testid', 'test');
});
});

This file was deleted.

0 comments on commit 0591bf3

Please sign in to comment.