Skip to content

Commit 63bbd97

Browse files
committed
test: cover scrollableInline logic
1 parent 48f3377 commit 63bbd97

3 files changed

Lines changed: 64 additions & 0 deletions

File tree

packages/eui/src/components/basic_table/basic_table.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,28 @@ describe('EuiBasicTable', () => {
862862
});
863863
});
864864

865+
// Should be in sync with the same test suite
866+
// in src/components/table/table.test.tsx
867+
// and src/components/basic_table/in_memory_table.test.tsx
868+
// to ensure equal behavior
869+
describe('scrollableInline', () => {
870+
it('updates table width styles when enabled', () => {
871+
const { getByRole, rerender } = render(
872+
<EuiBasicTable items={[]} columns={[]} />
873+
);
874+
let table = getByRole('table');
875+
876+
expect(table).toHaveStyleRule('inline-size', '100%');
877+
expect(table).not.toHaveStyleRule('min-inline-size');
878+
879+
rerender(<EuiBasicTable items={[]} columns={[]} scrollableInline />);
880+
table = getByRole('table');
881+
882+
expect(table).toHaveStyleRule('inline-size', 'auto');
883+
expect(table).toHaveStyleRule('min-inline-size', '100%');
884+
});
885+
});
886+
865887
it('renders (kitchen sink) with pagination, selection, sorting, actions, and footer', () => {
866888
const props: EuiBasicTableProps<AgeItem> = {
867889
items: [

packages/eui/src/components/basic_table/in_memory_table.test.tsx

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1673,4 +1673,26 @@ describe('EuiInMemoryTable', () => {
16731673
expect(searchbox.value).toBe('');
16741674
});
16751675
});
1676+
1677+
// Should be in sync with the same test suite
1678+
// in src/components/table/table.test.tsx
1679+
// and src/components/basic_table/basic_table.test.tsx
1680+
// to ensure equal behavior
1681+
describe('scrollableInline', () => {
1682+
it('updates table width styles when enabled', () => {
1683+
const { getByRole, rerender } = render(
1684+
<EuiInMemoryTable items={[]} columns={[]} />
1685+
);
1686+
let table = getByRole('table');
1687+
1688+
expect(table).toHaveStyleRule('inline-size', '100%');
1689+
expect(table).not.toHaveStyleRule('min-inline-size');
1690+
1691+
rerender(<EuiInMemoryTable items={[]} columns={[]} scrollableInline />);
1692+
table = getByRole('table');
1693+
1694+
expect(table).toHaveStyleRule('inline-size', 'auto');
1695+
expect(table).toHaveStyleRule('min-inline-size', '100%');
1696+
});
1697+
});
16761698
});

packages/eui/src/components/table/table.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,26 @@ describe('EuiTable', () => {
6969
});
7070
});
7171

72+
// Should be in sync with the same test suite
73+
// in src/components/basic_table/basic_table.test.tsx
74+
// and src/components/basic_table/in_memory_table.test.tsx
75+
// to ensure equal behavior
76+
describe('scrollableInline', () => {
77+
it('updates table width styles when enabled', () => {
78+
const { getByRole, rerender } = render(<EuiTable />);
79+
let table = getByRole('table');
80+
81+
expect(table).toHaveStyleRule('inline-size', '100%');
82+
expect(table).not.toHaveStyleRule('min-inline-size');
83+
84+
rerender(<EuiTable scrollableInline />);
85+
table = getByRole('table');
86+
87+
expect(table).toHaveStyleRule('inline-size', 'auto');
88+
expect(table).toHaveStyleRule('min-inline-size', '100%');
89+
});
90+
});
91+
7292
it('always renders responsive tables styles if set to `true`', () => {
7393
window.innerWidth = 2000;
7494
const { getByRole } = render(<EuiTable responsiveBreakpoint={true} />);

0 commit comments

Comments
 (0)