Skip to content

Commit

Permalink
Merge branch 'hotfix/table-column-fix'
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonhochkins committed May 16, 2023
2 parents f5d8ce9 + a9beda6 commit fa43944
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 1 deletion.
13 changes: 13 additions & 0 deletions _tests/molecules/Table.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import renderer from 'react-test-renderer';
import { render, fireEvent } from '@testing-library/react';
import React from 'react';
import Table from '../../components/molecules/Table';
import TableBody from '../../components/molecules/TableBody';
import TableData from '../../components/molecules/TableData';

const defaultProps = {
data: [
Expand Down Expand Up @@ -117,6 +119,17 @@ test('Expect <Table> to manually set sort direction', () => {
expect(heading).toHaveClass('gds-table__header--sort-asc');
});

test('Expect <Table> to render when used without columns prop', () => {
const tree = renderer.create(<Table>
<TableBody>
<TableData>
Foo
</TableData>
</TableBody>
</Table>).toJSON();
expect(tree).toMatchSnapshot();
});


test('Expect <Table> to render with expandable rows', () => {
const props = {
Expand Down
16 changes: 16 additions & 0 deletions _tests/molecules/__snapshots__/Table.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,22 @@ exports[`Expect <Table> to render using advanced configs 1`] = `
</table>
`;
exports[`Expect <Table> to render when used without columns prop 1`] = `
<table
className="gds-table"
>
<tbody
className=""
>
<td
className=""
>
Foo
</td>
</tbody>
</table>
`;
exports[`Expect <Table> to render with expandable rows 1`] = `
<table
className="gds-table custom-class gds-table--lg gds-table--expandable"
Expand Down
3 changes: 2 additions & 1 deletion components/molecules/Table.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,8 @@ Table.propTypes = {
};

Table.defaultProps = {
hasHeader: true
hasHeader: true,
columns: [],
};

export default Table;

0 comments on commit fa43944

Please sign in to comment.