From 4ca7baa64e721fd1ad03629fd8904df5ffad92ff Mon Sep 17 00:00:00 2001 From: Cee Chen Date: Fri, 1 Dec 2023 09:51:10 -0800 Subject: [PATCH] Update unit tests - to work around new non-jest/jsdom-friendly behavior --- .../selectable_list/selectable_list.test.tsx | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/components/selectable/selectable_list/selectable_list.test.tsx b/src/components/selectable/selectable_list/selectable_list.test.tsx index 140fa0ce4547..1d24a79ffa41 100644 --- a/src/components/selectable/selectable_list/selectable_list.test.tsx +++ b/src/components/selectable/selectable_list/selectable_list.test.tsx @@ -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( { }); 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(