Skip to content

Commit bebc44b

Browse files
committed
fix tests
1 parent 1bbd69c commit bebc44b

File tree

7 files changed

+26
-1
lines changed

7 files changed

+26
-1
lines changed

packages/@react-spectrum/autocomplete/test/SearchAutocomplete.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,8 @@ describe('SearchAutocomplete', function () {
143143
user = userEvent.setup({delay: null, pointerMap});
144144
jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(() => 1000);
145145
jest.spyOn(window.HTMLElement.prototype, 'clientHeight', 'get').mockImplementation(() => 1000);
146+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
147+
scrollHeight = jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
146148
window.HTMLElement.prototype.scrollIntoView = jest.fn();
147149
simulateDesktop();
148150
jest.useFakeTimers();

packages/@react-spectrum/card/test/CardView.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,14 @@ describe('CardView', function () {
141141
user = userEvent.setup({delay: null, pointerMap});
142142
jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(() => mockWidth);
143143
jest.spyOn(window.HTMLElement.prototype, 'clientHeight', 'get').mockImplementation(() => mockHeight);
144+
// jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
144145
jest.useFakeTimers();
145146
});
146147

148+
beforeEach(() => {
149+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
150+
})
151+
147152
afterEach(() => {
148153
jest.clearAllMocks();
149154
act(() => jest.runAllTimers());

packages/@react-spectrum/color/test/ColorPicker.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,14 @@ describe('ColorPicker', function () {
2222

2323
beforeAll(() => {
2424
user = userEvent.setup({delay: null, pointerMap});
25+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
2526
jest.useFakeTimers();
2627
});
2728

29+
afterAll(function () {
30+
jest.restoreAllMocks();
31+
});
32+
2833
afterEach(() => {
2934
act(() => {jest.runAllTimers();});
3035
});

packages/@react-spectrum/combobox/test/ComboBox.test.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -257,6 +257,7 @@ describe('ComboBox', function () {
257257
});
258258

259259
beforeEach(() => {
260+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
260261
load = jest
261262
.fn()
262263
.mockImplementationOnce(getFilterItems)
@@ -3667,6 +3668,7 @@ describe('ComboBox', function () {
36673668
describe('mobile combobox', function () {
36683669
beforeEach(() => {
36693670
simulateMobile();
3671+
36703672
});
36713673

36723674
afterEach(() => {

packages/@react-spectrum/picker/test/Picker.test.js

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ import {User} from '@react-aria/test-utils';
3131
import userEvent from '@testing-library/user-event';
3232

3333
describe('Picker', function () {
34-
let offsetWidth, offsetHeight;
34+
let offsetWidth, offsetHeight, scrollHeight;
3535
let onSelectionChange = jest.fn();
3636
let testUtilUser = new User();
3737
let user;
@@ -40,13 +40,15 @@ describe('Picker', function () {
4040
user = userEvent.setup({delay: null, pointerMap});
4141
offsetWidth = jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(() => 1000);
4242
offsetHeight = jest.spyOn(window.HTMLElement.prototype, 'clientHeight', 'get').mockImplementation(() => 1000);
43+
scrollHeight = jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
4344
simulateDesktop();
4445
jest.useFakeTimers();
4546
});
4647

4748
afterAll(function () {
4849
offsetWidth.mockReset();
4950
offsetHeight.mockReset();
51+
scrollHeight.mockReset();
5052
});
5153

5254
afterEach(() => {
@@ -91,6 +93,9 @@ describe('Picker', function () {
9193
expect(queryByRole('listbox')).toBeNull();
9294

9395
let picker = selectTester.trigger;
96+
// let picker = getByRole('button');
97+
// await user.click(picker);
98+
// act(() => jest.runAllTimers());
9499
await selectTester.open();
95100

96101
let listbox = selectTester.listbox;

packages/@react-spectrum/picker/test/TempUtilTest.test.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,14 @@ describe('Picker/Select ', function () {
2727

2828
beforeAll(function () {
2929
user = userEvent.setup({delay: null, pointerMap});
30+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
3031
simulateDesktop();
3132
});
3233

34+
afterAll(function () {
35+
jest.restoreAllMocks();
36+
});
37+
3338
describe('with real timers', function () {
3439
beforeAll(function () {
3540
jest.useRealTimers();

packages/@react-spectrum/tabs/test/Tabs.test.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,7 @@ describe('Tabs', function () {
6060
beforeEach(() => {
6161
jest.spyOn(window.HTMLElement.prototype, 'clientWidth', 'get').mockImplementation(() => 1000);
6262
jest.spyOn(window.HTMLElement.prototype, 'clientHeight', 'get').mockImplementation(() => 1000);
63+
jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get').mockImplementation(() => 50);
6364
window.HTMLElement.prototype.scrollIntoView = jest.fn();
6465
});
6566

0 commit comments

Comments
 (0)