Skip to content

Commit

Permalink
Update unit tests
Browse files Browse the repository at this point in the history
- to work around new non-jest/jsdom-friendly behavior
  • Loading branch information
cee-chen committed Dec 1, 2023
1 parent de96e8e commit 4ca7baa
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/components/selectable/selectable_list/selectable_list.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -362,6 +362,13 @@ describe('EuiSelectableListItem', () => {
});

describe('truncation performance optimization', () => {
// Mock requestAnimationFrame
beforeEach(() => {
jest
.spyOn(window, 'requestAnimationFrame')
.mockImplementation((cb: Function) => cb());
});

it('does not render EuiTextTruncate if not virtualized and text is wrapping', () => {
const { container } = render(
<EuiSelectableList
Expand Down Expand Up @@ -395,6 +402,12 @@ describe('EuiSelectableListItem', () => {
});

it('attempts to use a default optimized option width calculated from the wrapping EuiAutoSizer', () => {
// jsdom doesn't return valid element offsetWidths, so we have to mock it here
Object.defineProperty(HTMLElement.prototype, 'offsetWidth', {
configurable: true,
value: 600,
});

const { container } = render(
<EuiSelectableList
options={options}
Expand Down

0 comments on commit 4ca7baa

Please sign in to comment.