From 700917aefa9717744e31752e5aa9786f0a6fca2c Mon Sep 17 00:00:00 2001 From: jquense Date: Wed, 10 Jul 2024 15:03:55 -0400 Subject: [PATCH 1/8] WIP --- src/NavItem.tsx | 32 +++++++++++++++++--------------- test/ModalSpec.js | 6 ++---- test/{NavSpec.js => NavSpec.tsx} | 16 +++++++++------- 3 files changed, 28 insertions(+), 26 deletions(-) rename test/{NavSpec.js => NavSpec.tsx} (69%) diff --git a/src/NavItem.tsx b/src/NavItem.tsx index 58b1128..0fc20c1 100644 --- a/src/NavItem.tsx +++ b/src/NavItem.tsx @@ -117,21 +117,23 @@ export function useNavItem({ return [props, { isActive }] as const; } -const NavItem: DynamicRefForwardingComponent = - React.forwardRef( - ({ as: Component = Button, active, eventKey, ...options }, ref) => { - const [props, meta] = useNavItem({ - key: makeEventKey(eventKey, options.href), - active, - ...options, - }); - - // @ts-ignore - props[dataAttr('active')] = meta.isActive; - - return ; - }, - ); +const NavItem: DynamicRefForwardingComponent< + typeof Button, + NavItemProps +> = React.forwardRef( + ({ as: Component = Button, active, eventKey, ...options }, ref) => { + const [props, meta] = useNavItem({ + key: makeEventKey(eventKey, options.href), + active, + ...options, + }); + + // @ts-ignore + props[dataAttr('active')] = meta.isActive; + + return ; + }, +); NavItem.displayName = 'NavItem'; diff --git a/test/ModalSpec.js b/test/ModalSpec.js index 09485b9..5e58ae6 100644 --- a/test/ModalSpec.js +++ b/test/ModalSpec.js @@ -4,10 +4,8 @@ import * as React from 'react'; import ReactDOM from 'react-dom'; import { act } from 'react-dom/test-utils'; import Transition from 'react-transition-group/Transition'; -import simulant from 'simulant'; import { render } from '@testing-library/react'; -import { mount } from 'enzyme'; import Modal from '../src/Modal'; import { OPEN_DATA_ATTRIBUTE } from '../src/ModalManager'; @@ -18,8 +16,8 @@ describe('', () => { const mountWithRef = (el, options) => { const ref = React.createRef(); - const Why = (props) => React.cloneElement(el, { ...props, ref }); - wrapper = mount(, options); + + render(React.cloneElement(el, { ...el.props, ref }), options); return ref; }; diff --git a/test/NavSpec.js b/test/NavSpec.tsx similarity index 69% rename from test/NavSpec.js rename to test/NavSpec.tsx index 4cb88a6..0c3ac56 100644 --- a/test/NavSpec.js +++ b/test/NavSpec.tsx @@ -1,12 +1,13 @@ /* eslint-disable mocha/no-hooks-for-single-case */ -import { mount } from 'enzyme'; +import { fireEvent, render, screen } from '@testing-library/react'; +import { expect } from 'chai'; import Tabs from '../src/Tabs'; import Nav from '../src/Nav'; import NavItem from '../src/NavItem'; describe('