Skip to content
This repository has been archived by the owner on May 24, 2024. It is now read-only.

Commit

Permalink
added tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Sugan G authored and Sugan G committed Mar 1, 2024
1 parent 3a34383 commit 989737c
Show file tree
Hide file tree
Showing 9 changed files with 45 additions and 34 deletions.
43 changes: 22 additions & 21 deletions packages/terra-table/tests/jest/Row.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -63,27 +63,28 @@ describe('Row', () => {
expect(wrapper).toMatchSnapshot();
});

// it('creates a row with no row header', () => {
// const rowData = tableData.rows[0];
//
// const wrapper = enzyme.shallow(
// <Row
// rowIndex={99}
// id={rowData.id}
// tableId="test-table"
// height="25px"
// cells={rowData.cells}
// rowSelectionMode={tableData.rows[0].hasSelectableRows ? 'multiple' : undefined}
// displayedColumns={tableData.cols}
// rowHeaderIndex={-1}
// onCellSelect={jest.fn}
// onRowSelect={jest.fn}
// />,
// );
//
// const tableRow = wrapper.find(Row);
// const cells = tableRow.find(Cell);
// });
it('creates a row with no row header', () => {
const rowData = tableData.rows[0];

const wrapper = enzyme.shallow(
<Row
rowIndex={99}
id={rowData.id}
tableId="test-table"
height="25px"
cells={rowData.cells}
rowSelectionMode={tableData.rows[0].hasSelectableRows ? 'multiple' : undefined}
displayedColumns={tableData.cols}
rowHeaderIndex={-1}
onCellSelect={jest.fn}
onRowSelect={jest.fn}
/>,
);

const tableRow = wrapper.find('tr.row');
const renderedCells = tableRow.find(Cell);
expect(renderedCells.get(0).props.isRowHeader).toEqual(false);
});

it('verifies the cell is created with the right props', () => {
const rowIndex = 2;
Expand Down
29 changes: 16 additions & 13 deletions packages/terra-table/tests/jest/Table.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import GridContext, { GridConstants } from '../../src/utils/GridContext';
import ERRORS from '../../src/utils/constants';
import Row from '../../src/subcomponents/Row';
import Table from '../../src/Table';
import Cell from '../../src/subcomponents/Cell';

// Source data for tests
const tableData = {
Expand Down Expand Up @@ -182,19 +183,21 @@ describe('Table', () => {
expect(columnHeader).toHaveLength(1);
});

// it('verifies that the table created has no row headers', () => {
// const wrapper = enzymeIntl.mountWithIntl(
// <Table
// id="test-terra-table"
// pinnedColumns={tableData.cols.slice(0, 2)}
// overflowColumns={tableData.cols.slice(2)}
// rows={tableData.rows}
// rowHeaderIndex={-1}
// />,
// );
//
// const firstRow = wrapper.find(Row).at(0);
// });
it('verifies that the table created has no row headers', () => {
const wrapper = enzymeIntl.mountWithIntl(
<Table
id="test-terra-table"
pinnedColumns={tableData.cols.slice(0, 2)}
overflowColumns={tableData.cols.slice(2)}
rows={tableData.rows}
rowHeaderIndex={-1}
/>,
);

const firstRow = wrapper.find(Row).at(0);
const firstCell = firstRow.find(Cell).at(0);
expect(firstCell.props().isRowHeader).toEqual(false);
});

it('verifies row selection column header selection', () => {
const mockColumnSelect = jest.fn();
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 7 additions & 0 deletions packages/terra-table/tests/wdio/table-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -277,4 +277,11 @@ Terra.describeViewports('Table', ['medium', 'large'], () => {
Terra.validates.element('resizable-table', '#resizable-terra-table');
});
});

describe('Table with no row headers', () => {
it('Validates table with no row headers', () => {
browser.url('/raw/tests/cerner-terra-framework-docs/table/table-without-row-header');
Terra.validates.element('table-without-row-header', '#table-without-row-header');
});
});
});

0 comments on commit 989737c

Please sign in to comment.