Skip to content

Commit

Permalink
test: removed snapshot Table tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Kirill Kharitonov committed Jan 31, 2024
1 parent c593e24 commit 8557dda
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 721 deletions.
41 changes: 0 additions & 41 deletions src/components/Table/__tests__/Table.hocs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,47 +24,6 @@ function getTextContent(html = '') {
}

describe('Table HOCs tests', () => {
it('withTableActions should match snapshot', () => {
const Table1 = withTableActions<Model>(Table);

type Props = TableProps<Model> & WithTableActionsProps<Model>;
const props: Props = {
data: [{disabled: false}, {disabled: true}],
columns: [{id: 'name'}],
isRowDisabled: ({disabled}) => disabled,
getRowActions: () => [],
};
const {container} = render(React.createElement<Props>(Table1, props));

expect(container).toMatchSnapshot();
});

it('all HOCs should match snapshot', () => {
const Table1 = withTableSorting(
withTableSettings(withTableCopy(withTableActions(withTableSelection<Model>(Table)))),
);

type Props = TableProps<Model> &
WithTableActionsProps<Model> &
WithTableSelectionProps<Model> &
WithTableSettingsProps &
WithTableSortingProps;

const props: Props = {
data: [{disabled: false}, {disabled: true}],
columns: [{id: 'name'}],
isRowDisabled: ({disabled}) => disabled,
selectedIds: [],
onSelectionChange: () => {},
getRowActions: () => [],
updateSettings: () => Promise.resolve(),
settings: [],
};
const {container} = render(React.createElement<Props>(Table1, props));

expect(container).toMatchSnapshot();
});

it('using withTableActions and withTableSelection should not depend of order', () => {
const Table1 = withTableActions(withTableSelection<Model>(Table));
const Table2 = withTableSelection(withTableActions<Model>(Table));
Expand Down
69 changes: 0 additions & 69 deletions src/components/Table/__tests__/Table.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,75 +19,6 @@ describe('Table', () => {
expect(rows.length).toBe(data.length + 1);
});

test('should render empty state', () => {
const props: TableProps<DataItem> = {data: [], columns: [{id: 'name'}]};
const {container} = render(React.createElement<TableProps<DataItem>>(Table, props));

expect(container).toMatchSnapshot();
});

test('should correctly apply `align` prop', () => {
const props: TableProps<{}> = {
data: [{}],
columns: [
{id: 'name1', align: 'left'},
{id: 'name2', align: 'right'},
{id: 'name3', align: 'center'},
],
};
const {container} = render(React.createElement<TableProps<{}>>(Table, props));

expect(container).toMatchSnapshot();
});

test('should correctly apply `width` prop', () => {
const props: TableProps<{}> = {
data: [{}],
columns: [
{id: 'name1', width: 100},
{id: 'name2', width: 200},
{id: 'name3', width: 300},
],
};
const {container} = render(React.createElement<TableProps<{}>>(Table, props));

expect(container).toMatchSnapshot();
});

test('should correctly apply `primary` prop', () => {
const props: TableProps<{}> = {
data: [{}],
columns: [{id: 'name1', primary: true}, {id: 'name2', primary: false}, {id: 'name3'}],
};
const {container} = render(React.createElement<TableProps<{}>>(Table, props));

expect(container).toMatchSnapshot();
});

test('should correctly add custom row classnames', () => {
const props: TableProps<{}> = {
data: [{}],
columns: [{id: 'name'}],
getRowClassNames: () => ['custom-row', 'custom-row_mod'],
};
const {container} = render(React.createElement<TableProps<{}>>(Table, props));

expect(container).toMatchSnapshot();
});

test('should correctly add disabled classname', () => {
const props: TableProps<{disabled: boolean}> = {
data: [{disabled: false}, {disabled: true}],
columns: [{id: 'name'}],
isRowDisabled: ({disabled}) => disabled,
};
const {container} = render(
React.createElement<TableProps<{disabled: boolean}>>(Table, props),
);

expect(container).toMatchSnapshot();
});

test.each(new Array<'top' | 'middle'>('top', 'middle'))(
'render with given "%s" vertical align',
(align) => {
Expand Down
Loading

0 comments on commit 8557dda

Please sign in to comment.