Frontend tests improvements (#13115)
Fix warnings and lower coverage by 0.1%
This commit is contained in:
+1
-2
@@ -1,5 +1,4 @@
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
import { useDialogManagerScopedStates } from '@/ui/feedback/dialog-manager/hooks/internal/useDialogManagerScopedStates';
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
import { useSnackBarManagerScopedStates } from '@/ui/feedback/snack-bar-manager/hooks/internal/useSnackBarManagerScopedStates';
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { act } from 'react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
import { useIconPicker } from '@/ui/input/hooks/useIconPicker';
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { act } from 'react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
import { useSelectableList } from '@/ui/layout/selectable-list/hooks/useSelectableList';
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { act, renderHook } from '@testing-library/react';
|
||||
import { RecoilRoot, useRecoilValue } from 'recoil';
|
||||
|
||||
import { stepBarInternalState } from '../../states/stepBarInternalState';
|
||||
|
||||
+25
-16
@@ -1,4 +1,5 @@
|
||||
import { render } from '@testing-library/react';
|
||||
import { act } from 'react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
import { PointerEventListener } from '@/ui/utilities/pointer-event/types/PointerEventListener';
|
||||
@@ -70,10 +71,12 @@ describe('DragSelect', () => {
|
||||
preventDefault: jest.fn(),
|
||||
};
|
||||
|
||||
callbacks.onMouseDown({
|
||||
x: 150,
|
||||
y: 150,
|
||||
event: mockEvent,
|
||||
act(() => {
|
||||
callbacks.onMouseDown({
|
||||
x: 150,
|
||||
y: 150,
|
||||
event: mockEvent,
|
||||
});
|
||||
});
|
||||
|
||||
expect(mockEvent.preventDefault).not.toHaveBeenCalled();
|
||||
@@ -92,10 +95,12 @@ describe('DragSelect', () => {
|
||||
preventDefault: jest.fn(),
|
||||
};
|
||||
|
||||
callbacks.onMouseDown({
|
||||
x: 150,
|
||||
y: 150,
|
||||
event: mockEvent,
|
||||
act(() => {
|
||||
callbacks.onMouseDown({
|
||||
x: 150,
|
||||
y: 150,
|
||||
event: mockEvent,
|
||||
});
|
||||
});
|
||||
|
||||
expect(mockEvent.preventDefault).toHaveBeenCalled();
|
||||
@@ -131,10 +136,12 @@ describe('DragSelect', () => {
|
||||
.mockReturnValue(mockBoundaryElement);
|
||||
mockBoundaryElement.contains = jest.fn().mockReturnValue(true);
|
||||
|
||||
callbacks.onMouseDown({
|
||||
x: 150,
|
||||
y: 150,
|
||||
event: { target: mockTarget, preventDefault: jest.fn() },
|
||||
act(() => {
|
||||
callbacks.onMouseDown({
|
||||
x: 150,
|
||||
y: 150,
|
||||
event: { target: mockTarget, preventDefault: jest.fn() },
|
||||
});
|
||||
});
|
||||
|
||||
expect(mockSelectableContainer.closest).toHaveBeenCalledWith(
|
||||
@@ -160,10 +167,12 @@ describe('DragSelect', () => {
|
||||
mockSelectableContainer.contains = jest.fn().mockReturnValue(true);
|
||||
|
||||
expect(() => {
|
||||
callbacks.onMouseDown({
|
||||
x: 150,
|
||||
y: 150,
|
||||
event: { target: mockTarget, preventDefault: jest.fn() },
|
||||
act(() => {
|
||||
callbacks.onMouseDown({
|
||||
x: 150,
|
||||
y: 150,
|
||||
event: { target: mockTarget, preventDefault: jest.fn() },
|
||||
});
|
||||
});
|
||||
}).not.toThrow();
|
||||
});
|
||||
|
||||
+1
-1
@@ -1,5 +1,5 @@
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { act } from 'react';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
import { useDragSelect } from '../useDragSelect';
|
||||
|
||||
+1
-2
@@ -1,5 +1,4 @@
|
||||
import { fireEvent, renderHook } from '@testing-library/react';
|
||||
import { act } from 'react-dom/test-utils';
|
||||
import { act, fireEvent, renderHook } from '@testing-library/react';
|
||||
import { MemoryRouter, useLocation } from 'react-router-dom';
|
||||
import { RecoilRoot } from 'recoil';
|
||||
|
||||
|
||||
+12
-1
@@ -1,5 +1,5 @@
|
||||
import { createContext } from 'react';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { createContext } from 'react';
|
||||
|
||||
import { useContextScopeId } from '@/ui/utilities/recoil-scope/hooks/useContextScopeId';
|
||||
|
||||
@@ -25,8 +25,19 @@ describe('useContextScopeId', () => {
|
||||
});
|
||||
|
||||
it('Should throw an error when used outside of the specified context', () => {
|
||||
// Suppress console errors for this test since we're expecting an error
|
||||
/* eslint-disable no-console */
|
||||
const originalConsoleError = console.error;
|
||||
console.error = jest.fn();
|
||||
/* eslint-enable no-console */
|
||||
|
||||
expect(() => {
|
||||
renderHook(() => useContextScopeId(nullContext));
|
||||
}).toThrow(ERROR_MESSAGE);
|
||||
|
||||
// Restore console.error
|
||||
/* eslint-disable no-console */
|
||||
console.error = originalConsoleError;
|
||||
/* eslint-enable no-console */
|
||||
});
|
||||
});
|
||||
|
||||
+12
-1
@@ -1,5 +1,5 @@
|
||||
import { createContext } from 'react';
|
||||
import { renderHook } from '@testing-library/react';
|
||||
import { createContext } from 'react';
|
||||
|
||||
import { useRecoilScopeId } from '@/ui/utilities/recoil-scope/hooks/useRecoilScopeId';
|
||||
|
||||
@@ -25,8 +25,19 @@ describe('useRecoilScopeId', () => {
|
||||
});
|
||||
|
||||
it('Should throw an error when used outside of the specified context', () => {
|
||||
// Suppress console errors for this test since we're expecting an error
|
||||
/* eslint-disable no-console */
|
||||
const originalConsoleError = console.error;
|
||||
console.error = jest.fn();
|
||||
/* eslint-enable no-console */
|
||||
|
||||
expect(() => {
|
||||
renderHook(() => useRecoilScopeId(nullContext));
|
||||
}).toThrow(ERROR_MESSAGE);
|
||||
|
||||
// Restore console.error
|
||||
/* eslint-disable no-console */
|
||||
console.error = originalConsoleError;
|
||||
/* eslint-enable no-console */
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user