Skip to content

Commit

Permalink
test(EuiTableRow): fix validateDOMNesting warning
Browse files Browse the repository at this point in the history
 PASS  src/components/table/table_row.test.tsx
  ● Console

    console.warn scripts/jest/setup/throw_on_console_error.js:49
      Warning: validateDOMNesting(...): <tr> cannot appear as a child of <div>.
          at tr
          at EuiTableRow (/home/jun/Desktop/github/waiting-for-pr/eui/src/components/table/table_row.tsx:52:3)
          at /home/jun/Desktop/github/waiting-for-pr/eui/node_modules/@emotion/react/dist/emotion-element-48d2c2e4.cjs.dev.js:62:23
          at CurrentEuiBreakpointProvider (/home/jun/Desktop/github/waiting-for-pr/eui/src/services/breakpoint/current_breakpoint.tsx:39:8)
          at EuiComponentDefaultsProvider (/home/jun/Desktop/github/waiting-for-pr/eui/src/components/provider/component_defaults/component_defaults.tsx:59:8)
          at ThemeProvider (/home/jun/Desktop/github/waiting-for-pr/eui/node_modules/@emotion/react/dist/emotion-element-48d2c2e4.cjs.dev.js:125:32)
          at EuiEmotionThemeProvider (/home/jun/Desktop/github/waiting-for-pr/eui/src/services/theme/emotion.tsx:25:8)
          at EuiThemeProvider (/home/jun/Desktop/github/waiting-for-pr/eui/src/services/theme/provider.tsx:62:3)
          at EuiCacheProvider (/home/jun/Desktop/github/waiting-for-pr/eui/src/components/provider/cache/cache_provider.tsx:18:3)
          at EuiProviderNestedCheck (/home/jun/Desktop/github/waiting-for-pr/eui/src/components/provider/nested/nested_context.tsx:20:42)
          at EuiProvider (/home/jun/Desktop/github/waiting-for-pr/eui/src/components/provider/provider.tsx:87:3)

Signed-off-by: Eng Zer Jun <[email protected]>
  • Loading branch information
Juneezee committed Feb 4, 2024
1 parent 8ff1fca commit ac3ddd6
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 33 deletions.
70 changes: 39 additions & 31 deletions src/components/table/__snapshots__/table_row.test.tsx.snap
Original file line number Diff line number Diff line change
@@ -1,41 +1,49 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`isSelected renders true when specified 1`] = `
<tr
class="euiTableRow euiTableRow-isSelected"
>
<td
class="euiTableRowCell euiTableRowCell--middle"
>
<div
class="euiTableCellContent"
<table>
<tbody>
<tr
class="euiTableRow euiTableRow-isSelected"
>
<span
class="euiTableCellContent__text"
/>
</div>
</td>
</tr>
<td
class="euiTableRowCell euiTableRowCell--middle"
>
<div
class="euiTableCellContent"
>
<span
class="euiTableCellContent__text"
/>
</div>
</td>
</tr>
</tbody>
</table>
`;

exports[`renders EuiTableRow 1`] = `
<tr
aria-label="aria-label"
class="euiTableRow testClass1 testClass2 emotion-euiTestCss"
data-test-subj="test subject string"
>
<td
class="euiTableRowCell euiTableRowCell--middle"
>
<div
class="euiTableCellContent"
<table>
<tbody>
<tr
aria-label="aria-label"
class="euiTableRow testClass1 testClass2 emotion-euiTestCss"
data-test-subj="test subject string"
>
<span
class="euiTableCellContent__text"
<td
class="euiTableRowCell euiTableRowCell--middle"
>
hi
</span>
</div>
</td>
</tr>
<div
class="euiTableCellContent"
>
<span
class="euiTableCellContent__text"
>
hi
</span>
</div>
</td>
</tr>
</tbody>
</table>
`;
12 changes: 10 additions & 2 deletions src/components/table/table_row.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ import { EuiTableRow } from './table_row';

import { EuiTableRowCell } from './table_row_cell';

function renderTable(ui: React.ReactElement) {
return render(
<table>
<tbody>{ui}</tbody>
</table>
);
}

test('renders EuiTableRow', () => {
const { container } = render(
const { container } = renderTable(
<EuiTableRow {...requiredProps}>
<EuiTableRowCell>hi</EuiTableRowCell>
</EuiTableRow>
Expand All @@ -26,7 +34,7 @@ test('renders EuiTableRow', () => {

describe('isSelected', () => {
test('renders true when specified', () => {
const { container } = render(
const { container } = renderTable(
<EuiTableRow isSelected={true}>
<EuiTableRowCell />
</EuiTableRow>
Expand Down

0 comments on commit ac3ddd6

Please sign in to comment.