diff --git a/jest.config.ts b/jest.config.ts index 3d035eb9..2d71696e 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -20,7 +20,14 @@ export default { collectCoverage: true, // An array of glob patterns indicating a set of files for which coverage information should be collected - // collectCoverageFrom: undefined, + collectCoverageFrom: [ + 'src/**/*.{ts,tsx,js,jsx,css}', + // dev stuff + '!src/*', + '!src/**/*.d.ts', + // deprecated + '!src/components/TooltipProvider/*', + ], // The directory where Jest should output its coverage files coverageDirectory: 'coverage', diff --git a/src/components/Tooltip/Tooltip.tsx b/src/components/Tooltip/Tooltip.tsx index 14005d90..a35b5017 100644 --- a/src/components/Tooltip/Tooltip.tsx +++ b/src/components/Tooltip/Tooltip.tsx @@ -1,14 +1,16 @@ import React, { useEffect, useState, useRef, useCallback, useImperativeHandle } from 'react' import { autoUpdate } from '@floating-ui/dom' import classNames from 'classnames' -import debounce from 'utils/debounce' +import { + debounce, + deepEqual, + useIsomorphicLayoutEffect, + getScrollParent, + computeTooltipPosition, + cssTimeToMs, +} from 'utils' +import type { IComputedPosition } from 'utils' import { useTooltip } from 'components/TooltipProvider' -import useIsomorphicLayoutEffect from 'utils/use-isomorphic-layout-effect' -import { getScrollParent } from 'utils/get-scroll-parent' -import { computeTooltipPosition } from 'utils/compute-positions' -import type { IComputedPosition } from 'utils/compute-positions-types' -import { cssTimeToMs } from 'utils/css-time-to-ms' -import { deepEqual } from 'utils/deep-equal' import coreStyles from './core-styles.module.css' import styles from './styles.module.css' import type { diff --git a/src/components/TooltipController/TooltipController.tsx b/src/components/TooltipController/TooltipController.tsx index f22e4c64..cfe88d58 100644 --- a/src/components/TooltipController/TooltipController.tsx +++ b/src/components/TooltipController/TooltipController.tsx @@ -13,7 +13,7 @@ import type { } from 'components/Tooltip/TooltipTypes' import { useTooltip } from 'components/TooltipProvider' import { TooltipContent } from 'components/TooltipContent' -import cssSupports from 'utils/css-supports' +import { cssSupports } from 'utils' import classNames from 'classnames' import type { ITooltipController } from './TooltipControllerTypes' @@ -194,10 +194,12 @@ const TooltipController = React.forwardRef( if (styleInjectionRef.current === disableStyleInjection) { return } + /* c8 ignore start */ if (process.env.NODE_ENV !== 'production') { // eslint-disable-next-line no-console console.warn('[react-tooltip] Do not change `disableStyleInjection` dynamically.') } + /* c8 ignore end */ }, [disableStyleInjection]) useEffect(() => { @@ -227,10 +229,12 @@ const TooltipController = React.forwardRef( elementRefs.add({ current: anchor }) }) } catch { + /* c8 ignore start */ if (!process.env.NODE_ENV || process.env.NODE_ENV !== 'production') { // eslint-disable-next-line no-console console.warn(`[react-tooltip] "${selector}" is not a valid CSS selector`) } + /* c8 ignore end */ } } @@ -281,9 +285,11 @@ const TooltipController = React.forwardRef( }, [anchorRefs, providerActiveAnchor, activeAnchor, anchorId, anchorSelect]) useEffect(() => { + /* c8 ignore start */ if (process.env.NODE_ENV === 'production') { return } + /* c8 ignore end */ if (style?.border) { // eslint-disable-next-line no-console console.warn('[react-tooltip] Do not set `style.border`. Use `border` prop instead.') diff --git a/src/test/__snapshots__/tooltip-attributes.spec.js.snap b/src/test/__snapshots__/tooltip-attributes.spec.js.snap index 15d58fd8..9f36495b 100644 --- a/src/test/__snapshots__/tooltip-attributes.spec.js.snap +++ b/src/test/__snapshots__/tooltip-attributes.spec.js.snap @@ -4,12 +4,13 @@ exports[`tooltip attributes basic tooltip 1`] = `
Lorem Ipsum