Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
- Needed to define `IntersectionObserver` on the `window`
  • Loading branch information
mofojed committed Dec 27, 2024
1 parent cfed54e commit e121c90
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
6 changes: 6 additions & 0 deletions jest.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,12 @@ Object.defineProperty(window, 'ResizeObserver', {
},
});

Object.defineProperty(window, 'IntersectionObserver', {
value: function () {
return TestUtils.createMockProxy<IntersectionObserver>();
},
});

Object.defineProperty(window, 'DOMRect', {
value: function (x: number = 0, y: number = 0, width = 0, height = 0) {
return TestUtils.createMockProxy<DOMRect>({
Expand Down
2 changes: 1 addition & 1 deletion packages/console/src/Console.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ export class Console extends PureComponent<ConsoleProps, ConsoleState> {
this.consoleHistoryScrollPane = React.createRef();
this.pending = new Pending();
this.queuedLogMessages = [];
this.visibilityObserver = new IntersectionObserver(
this.visibilityObserver = new window.IntersectionObserver(
this.handleVisibilityChange
);

Expand Down

0 comments on commit e121c90

Please sign in to comment.