Skip to content

Commit

Permalink
test: fix test case
Browse files Browse the repository at this point in the history
  • Loading branch information
zombieJ committed Jan 28, 2025
1 parent a7250fa commit eec84a1
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 5 deletions.
2 changes: 1 addition & 1 deletion tests/FixedColumn-IE.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { spyElementPrototype } from '@rc-component/util/lib/test/domHook';
import React from 'react';
import { act } from 'react-dom/test-utils';
// eslint-disable-next-line @typescript-eslint/no-unused-vars
import RcResizeObserver from 'rc-resize-observer';
import RcResizeObserver from '@rc-component/resize-observer';
import Table from '../src';

vi.mock('@rc-component/util/lib/Dom/styleChecker', () => {
Expand Down
2 changes: 1 addition & 1 deletion tests/FixedColumn.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { mount } from 'enzyme';
import { render } from '@testing-library/react';
import RcResizeObserver, { _rs } from 'rc-resize-observer';
import RcResizeObserver, { _rs } from '@rc-component/resize-observer';
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
import { act } from 'react-dom/test-utils';
import Table, { type ColumnsType } from '../src';
Expand Down
2 changes: 1 addition & 1 deletion tests/FixedHeader.spec.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { mount } from 'enzyme';
import RcResizeObserver from 'rc-resize-observer';
import RcResizeObserver from '@rc-component/resize-observer';
import { spyElementPrototype } from '@rc-component/util/lib/test/domHook';
import React from 'react';
import { act } from 'react-dom/test-utils';
Expand Down
4 changes: 2 additions & 2 deletions tests/Virtual.spec.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { act, fireEvent, render } from '@testing-library/react';
import { _rs as onEsResize } from 'rc-resize-observer/es/utils/observerUtil';
import { _rs as onLibResize } from 'rc-resize-observer/lib/utils/observerUtil';
import { _rs as onEsResize } from '@rc-component/resize-observer/es/utils/observerUtil';
import { _rs as onLibResize } from '@rc-component/resize-observer/lib/utils/observerUtil';
import { spyElementPrototypes } from '@rc-component/util/lib/test/domHook';
import { resetWarned } from '@rc-component/util/lib/warning';
import React from 'react';
Expand Down
15 changes: 15 additions & 0 deletions tests/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,3 +13,18 @@ const Enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');

Enzyme.configure({ adapter: new Adapter() });

// Mock ResizeObserver
global.ResizeObserver = class ResizeObserver implements ResizeObserver {
callback: ResizeObserverCallback;

constructor(callback: ResizeObserverCallback) {
this.callback = callback;
}
observe(ele) {
// Mock trigger first time
this.callback([{ target: ele }] as any, this);
}
unobserve() {}
disconnect() {}
};

0 comments on commit eec84a1

Please sign in to comment.