diff --git a/package.json b/package.json index d203708f0..f671ecf3d 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@openstax/ui-components", - "version": "1.7.8", + "version": "1.7.9", "license": "MIT", "source": "./src/index.ts", "types": "./dist/index.d.ts", diff --git a/src/components/NavBar.tsx b/src/components/NavBar.tsx index eeedc5e4a..074c0d3b8 100644 --- a/src/components/NavBar.tsx +++ b/src/components/NavBar.tsx @@ -1,4 +1,4 @@ -import { navDesktopHeight, navMobileHeight } from '../../src/constants'; +import * as Constants from '../../src/constants'; import styled, { css } from 'styled-components'; import theme from '../../src/theme'; import { NavBarLogo as OpenstaxLogo } from './NavBarLogo'; @@ -44,18 +44,18 @@ type NavBarProps = React.PropsWithChildren<{ justifyContent?: string; }> -export const NavBar = ({ logo = false, maxWidth, ...props }: NavBarProps) => { +export const NavBar = ({ logo = false, maxWidth, navDesktopHeight, navMobileHeight, justifyContent, ...props }: NavBarProps) => { const logoIsObject = typeof logo === 'object'; const renderAnchor = logoIsObject && 'href' in logo; const {alt = 'OpenStax Logo', ...anchorProps} = logoIsObject ? logo : {}; const logoComponent = logo ? : null; - return + return {renderAnchor ? {logoComponent} : logoComponent} {props.children} diff --git a/src/components/Radio.spec.tsx b/src/components/Radio.spec.tsx index aeeb97275..d481c73fa 100644 --- a/src/components/Radio.spec.tsx +++ b/src/components/Radio.spec.tsx @@ -1,5 +1,6 @@ import { Radio } from './Radio'; import renderer from 'react-test-renderer'; +import { render, fireEvent } from '@testing-library/react'; describe('Radio', () => { it('matches snapshot', () => { @@ -8,4 +9,17 @@ describe('Radio', () => { ).toJSON(); expect(tree).toMatchSnapshot(); }); + + it('matches disabled snapshot', () => { + const tree = renderer.create( + Disabled + ).toJSON(); + expect(tree).toMatchSnapshot(); + }); + + it('calls onFocus handler', () => { + const { getByRole } = render(Click Me); + const radioButton = getByRole('radio'); + fireEvent.focus(radioButton); + }); }); diff --git a/src/components/Tooltip.spec.tsx b/src/components/Tooltip.spec.tsx index 7699dba12..76a0431dd 100644 --- a/src/components/Tooltip.spec.tsx +++ b/src/components/Tooltip.spec.tsx @@ -19,4 +19,11 @@ describe('Tooltip', () => { ).toJSON(); expect(tree).toMatchSnapshot(); }); + + it('uses icon', () => { + const tree = renderer.create( + Tooltip content + ).toJSON(); + expect(tree).toMatchSnapshot(); + }); }); diff --git a/src/components/__snapshots__/NavBar.spec.tsx.snap b/src/components/__snapshots__/NavBar.spec.tsx.snap index e1f5efe3d..2f1928ecd 100644 --- a/src/components/__snapshots__/NavBar.spec.tsx.snap +++ b/src/components/__snapshots__/NavBar.spec.tsx.snap @@ -3,6 +3,7 @@ exports[`NavBar matches snapshot 1`] = `
+ + Disabled + +`; + exports[`Radio matches snapshot 1`] = `