Renamed nullable utils into isDefined and isUndefinedOrNull (#4402)

* Renamed nullable utils into isDefined and isUndefinedOrNull
This commit is contained in:
Lucas Bordeau
2024-03-11 14:28:57 +01:00
committed by GitHub
parent 3f15cc5b7a
commit 581dfafe11
169 changed files with 469 additions and 493 deletions

View File

@ -2,7 +2,7 @@ import React from 'react';
import { act } from 'react-dom/test-utils';
import { fireEvent, render, renderHook } from '@testing-library/react';
import { isNonNullable } from '~/utils/isNonNullable';
import { isDefined } from '~/utils/isDefined';
import {
ClickOutsideMode,
@ -48,7 +48,7 @@ describe('useListenClickOutside', () => {
);
act(() => {
if (isNonNullable(containerRef.current)) {
if (isDefined(containerRef.current)) {
fireEvent.mouseDown(containerRef.current);
fireEvent.click(containerRef.current);
}
@ -97,7 +97,7 @@ describe('useListenClickOutsideByClassName', () => {
act(() => {
const notClickableElement = container.querySelector('.will-trigger');
if (isNonNullable(notClickableElement)) {
if (isDefined(notClickableElement)) {
fireEvent.mouseDown(notClickableElement);
fireEvent.click(notClickableElement);
}
@ -124,7 +124,7 @@ describe('useListenClickOutsideByClassName', () => {
act(() => {
const notClickableElement = container.querySelector('.wont-trigger');
if (isNonNullable(notClickableElement)) {
if (isDefined(notClickableElement)) {
fireEvent.mouseDown(notClickableElement);
fireEvent.click(notClickableElement);
}

View File

@ -7,7 +7,7 @@ import {
ClickOutsideMode,
useListenClickOutsideV2,
} from '@/ui/utilities/pointer-event/hooks/useListenClickOutsideV2';
import { isNonNullable } from '~/utils/isNonNullable';
import { isDefined } from '~/utils/isDefined';
const containerRef = React.createRef<HTMLDivElement>();
const nullRef = React.createRef<HTMLDivElement>();
@ -77,7 +77,7 @@ describe('useListenClickOutsideV2', () => {
);
act(() => {
if (isNonNullable(containerRef.current)) {
if (isDefined(containerRef.current)) {
fireEvent.mouseDown(containerRef.current);
fireEvent.click(containerRef.current);
}
@ -101,7 +101,7 @@ describe('useListenClickOutsideV2', () => {
);
act(() => {
if (isNonNullable(containerRef.current)) {
if (isDefined(containerRef.current)) {
fireEvent.mouseDown(containerRef.current);
fireEvent.click(containerRef.current);
}

View File

@ -8,7 +8,7 @@ import {
} from '@/ui/utilities/pointer-event/hooks/useListenClickOutsideV2';
import { ClickOutsideListenerCallback } from '@/ui/utilities/pointer-event/types/ClickOutsideListenerCallback';
import { getScopeIdFromComponentId } from '@/ui/utilities/recoil-scope/utils/getScopeIdFromComponentId';
import { isNonNullable } from '~/utils/isNonNullable';
import { isDefined } from '~/utils/isDefined';
export const useClickOutsideListener = (componentId: string) => {
// TODO: improve typing
@ -67,7 +67,7 @@ export const useClickOutsideListener = (componentId: string) => {
(callback) => callback.callbackId === callbackId,
);
if (!isNonNullable(existingCallbackWithSameId)) {
if (!isDefined(existingCallbackWithSameId)) {
const existingCallbacksWithNewCallback = existingCallbacks.concat({
callbackId,
callbackFunction,