Skip to content

Commit 847498c

Browse files
committed
fix more tests for jsdom 30 compatibility
1 parent 60b71ca commit 847498c

5 files changed

Lines changed: 11 additions & 8 deletions

File tree

src/checkbox/__tests__/checkbox.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -324,7 +324,7 @@ test('all style api properties', () => {
324324
expect(getComputedStyle(control).getPropertyValue(customCssProps.styleFocusRingBorderColor)).toBe('blue');
325325
expect(getComputedStyle(control).getPropertyValue(customCssProps.styleFocusRingBorderRadius)).toBe('1px');
326326
expect(getComputedStyle(control).getPropertyValue(customCssProps.styleFocusRingBorderWidth)).toBe('2px');
327-
expect(getComputedStyle(label).getPropertyValue('color')).toBe('orange');
327+
expect(getComputedStyle(label).getPropertyValue('color')).toBe('rgb(255, 165, 0)');
328328
});
329329

330330
describe('native attributes', () => {

src/error-boundary/__tests__/error-boundary.test.tsx

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -614,16 +614,19 @@ describe('built-in error boundaries', () => {
614614
describe('default behaviors', () => {
615615
test('window reload is called when the refresh action is clicked', () => {
616616
const mockReload = jest.fn();
617-
jest.spyOn(window.location, 'reload').mockImplementation(mockReload);
617+
Object.defineProperty(window.location, 'reload', { configurable: true, writable: true, value: mockReload });
618618

619619
renderWithErrorBoundary(<b>{{}}</b>);
620620
findRefreshAction()!.click();
621621
expect(mockReload).toHaveBeenCalledTimes(1);
622622
});
623623

624624
test('hides default refresh in cross-origin iframes', () => {
625-
jest.spyOn(window.location, 'href', 'get').mockImplementation(() => {
626-
throw new Error();
625+
Object.defineProperty(window.location, 'href', {
626+
configurable: true,
627+
get() {
628+
throw new Error();
629+
},
627630
});
628631

629632
renderWithErrorBoundary(<b>{{}}</b>);

src/pie-chart/__tests__/pie-chart.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -483,7 +483,7 @@ describe('Details popover', () => {
483483
const { wrapper } = renderPieChart(<PieChart data={defaultData} />);
484484
wrapper.findApplication()!.focus();
485485
expect(wrapper.findDetailPopover()).toBeTruthy();
486-
wrapper.findApplication()!.blur();
486+
fireEvent.blur(wrapper.findApplication()!.getElement(), { relatedTarget: document.body });
487487
expect(wrapper.findDetailPopover()).toBeNull();
488488
});
489489

src/radio-group/__tests__/radio-group.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,8 @@ test('all style api properties', function () {
443443
expect(getComputedStyle(outerCircle).getPropertyValue('fill')).toBe('blue');
444444
expect(getComputedStyle(outerCircle).getPropertyValue('stroke')).toBe('green');
445445
expect(getComputedStyle(innerCircle).getPropertyValue('stroke')).toBe('blue');
446-
expect(getComputedStyle(label).getPropertyValue('color')).toBe('brown');
447-
expect(getComputedStyle(description).getPropertyValue('color')).toBe('yellow');
446+
expect(getComputedStyle(label).getPropertyValue('color')).toBe('rgb(165, 42, 42)');
447+
expect(getComputedStyle(description).getPropertyValue('color')).toBe('rgb(255, 255, 0)');
448448
expect(getComputedStyle(control).getPropertyValue(customCssProps.styleFocusRingBorderColor)).toBe('orange');
449449
expect(getComputedStyle(control).getPropertyValue(customCssProps.styleFocusRingBorderRadius)).toBe('2px');
450450
expect(getComputedStyle(control).getPropertyValue(customCssProps.styleFocusRingBorderWidth)).toBe('1px');

src/test-utils/dom/collection-preferences/visible-content-preference.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export default class VisibleContentPreferenceWrapper extends ComponentWrapper {
3131
*/
3232
findToggleByIndex(groupIndex: number, optionIndex: number): ToggleWrapper | null {
3333
const groupSelector = `.${getClassName('groups')} > *:nth-child(${groupIndex})`;
34-
const optionSelector = `.${getClassName('option')}:nth-child(${optionIndex})`;
34+
const optionSelector = `*:nth-child(${optionIndex}).${getClassName('option')}`;
3535
return this.findComponent(`${groupSelector} ${optionSelector} .${getClassName('toggle')}`, ToggleWrapper);
3636
}
3737
}

0 commit comments

Comments
 (0)