Skip to content

Commit

Permalink
Merge branch 'tab-nav' into tabnav-aria
Browse files Browse the repository at this point in the history
  • Loading branch information
Emily Plummer committed Mar 2, 2021
2 parents a184e70 + fdb10f6 commit e60abef
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/TabNav.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ const TabNavBody = styled.nav`

export type TabNavProps = ComponentProps<typeof TabNavBase>

function TabNav({children, ...rest}: TabNavProps) {
function TabNav({children, "aria-label": ariaLabel, ...rest}: TabNavProps) {
return (
<TabNavBase {...rest}>
<TabNavBody>{children}</TabNavBody>
<TabNavBody aria-label={ariaLabel}>{children}</TabNavBody>
</TabNavBase>
)
}
Expand Down
8 changes: 5 additions & 3 deletions src/__tests__/TabNav.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import React from 'react'
import {TabNav} from '..'
import {mount, render, rendersClass, behavesAsComponent, checkExports} from '../utils/testing'
import {render, behavesAsComponent, checkExports} from '../utils/testing'
import {COMMON} from '../constants'
import {render as HTMLRender, cleanup} from '@testing-library/react'
import {axe, toHaveNoViolations} from 'jest-axe'
Expand All @@ -19,13 +19,15 @@ describe('TabNav', () => {
})

it('should have no axe violations', async () => {
const {container} = HTMLRender(<TabNav />)
const {container} = HTMLRender(<TabNav aria-label="main" />)
const results = await axe(container)
expect(results).toHaveNoViolations()
cleanup()
})

it('sets aria-label appropriately', () => {
expect(render(<TabNav aria-label="foo" />).props['aria-label']).toEqual('foo')
const {getByLabelText} = HTMLRender(<TabNav aria-label="stuff"/>)
expect(getByLabelText("stuff")).toBeTruthy();
expect(getByLabelText("stuff").tagName).toEqual("NAV")
})
})

0 comments on commit e60abef

Please sign in to comment.