test: improve utils coverage (#4230)
* test: improve utils coverage * refactor: review - rename isDefined to isNonNullable, update tests and return statement
This commit is contained in:
@ -5,7 +5,7 @@ import { Key } from 'ts-key-enum';
|
||||
import { FieldDoubleText } from '@/object-record/record-field/types/FieldDoubleText';
|
||||
import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||
import { useListenClickOutside } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
import { StyledInput } from './TextInput';
|
||||
|
||||
@ -147,7 +147,7 @@ export const DoubleTextInput = ({
|
||||
secondValue: secondInternalValue,
|
||||
});
|
||||
},
|
||||
enabled: isDefined(onClickOutside),
|
||||
enabled: isNonNullable(onClickOutside),
|
||||
});
|
||||
|
||||
return (
|
||||
|
||||
@ -10,7 +10,7 @@ import { useScopedHotkeys } from '@/ui/utilities/hotkey/hooks/useScopedHotkeys';
|
||||
import { useClickOutsideListener } from '@/ui/utilities/pointer-event/hooks/useClickOutsideListener';
|
||||
import { ClickOutsideMode } from '@/ui/utilities/pointer-event/hooks/useListenClickOutside';
|
||||
import { useIsMobile } from '@/ui/utilities/responsive/hooks/useIsMobile';
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
import { useRightDrawer } from '../hooks/useRightDrawer';
|
||||
import { isRightDrawerExpandedState } from '../states/isRightDrawerExpandedState';
|
||||
@ -84,7 +84,7 @@ export const RightDrawer = () => {
|
||||
: theme.rightDrawerWidth
|
||||
: '0';
|
||||
|
||||
if (!isDefined(rightDrawerPage)) {
|
||||
if (!isNonNullable(rightDrawerPage)) {
|
||||
return <></>;
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useRecoilCallback } from 'recoil';
|
||||
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
import { DEFAULT_HOTKEYS_SCOPE_CUSTOM_SCOPES } from '../constants/DefaultHotkeysScopeCustomScopes';
|
||||
import { currentHotkeyScopeState } from '../states/internal/currentHotkeyScopeState';
|
||||
@ -30,7 +30,7 @@ export const useSetHotkeyScope = () =>
|
||||
.valueOrThrow();
|
||||
|
||||
if (currentHotkeyScope.scope === hotkeyScopeToSet) {
|
||||
if (!isDefined(customScopes)) {
|
||||
if (!isNonNullable(customScopes)) {
|
||||
if (
|
||||
isCustomScopesEqual(
|
||||
currentHotkeyScope?.customScopes,
|
||||
|
||||
@ -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 { isDefined } from '~/utils/isDefined';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
export const useClickOutsideListener = (componentId: string) => {
|
||||
// TODO: improve typing
|
||||
@ -67,7 +67,7 @@ export const useClickOutsideListener = (componentId: string) => {
|
||||
(callback) => callback.callbackId === callbackId,
|
||||
);
|
||||
|
||||
if (!isDefined(existingCallbackWithSameId)) {
|
||||
if (!isNonNullable(existingCallbackWithSameId)) {
|
||||
const existingCallbacksWithNewCallback = existingCallbacks.concat({
|
||||
callbackId,
|
||||
callbackFunction,
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useContext } from 'react';
|
||||
|
||||
import { isDefined } from '~/utils/isDefined';
|
||||
import { isNonNullable } from '~/utils/isNonNullable';
|
||||
|
||||
import { ScopeInternalContext } from '../types/ScopeInternalContext';
|
||||
|
||||
@ -9,7 +9,7 @@ export const useScopeInternalContextOrThrow = <T extends { scopeId: string }>(
|
||||
) => {
|
||||
const context = useContext(Context);
|
||||
|
||||
if (!isDefined(context)) {
|
||||
if (!isNonNullable(context)) {
|
||||
throw new Error(
|
||||
`Using a scope context without a ScopeInternalContext.Provider wrapper for context : ${Context.displayName}.`,
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user