Skip to content

Commit

Permalink
refactor: apply code review comments (pairing session)
Browse files Browse the repository at this point in the history
  • Loading branch information
kabaros committed Mar 18, 2024
1 parent 8a64d2c commit e1400a3
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 22 deletions.
5 changes: 3 additions & 2 deletions components/button/src/split-button/split-button.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import PropTypes from 'prop-types'
import React, { Component } from 'react'
import css from 'styled-jsx/css'
import { Button } from '../index.js'
import i18n from '../locales/index.js'

const rightButton = css.resolve`
button {
Expand Down Expand Up @@ -113,8 +114,8 @@ class SplitButton extends Component {
tabIndex={tabIndex}
className={cx(className, rightButton.className)}
dataTest={`${dataTest}-toggle`}
title="Toggle dropdown"
aria-label="Toggle dropdown"
title={i18n.t('Toggle dropdown')}
aria-label={i18n.t('Toggle dropdown')}
>
{arrow}
</Button>
Expand Down
21 changes: 1 addition & 20 deletions components/button/src/split-button/split-button.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ describe('SplitButton', () => {
expect(getByText('Click me')).toBeInTheDocument()
})

it('toggles dropdown when right button is clicked', () => {
it('toggles dropdown when left button is clicked', () => {
const { getByTestId, queryByTestId } = render(<SplitButton />)
const toggleButton = getByTestId('dhis2-uicore-splitbutton-toggle')

Expand Down Expand Up @@ -56,25 +56,6 @@ describe('SplitButton', () => {
})
})

it("does not close dropdown 'SpaceBar' key is pressed", async () => {
const { getByTestId } = render(
<SplitButton component={<div>Dropdown Content</div>} />
)

const toggleButton = getByTestId('dhis2-uicore-splitbutton-toggle')
fireEvent.click(toggleButton)
expect(getByTestId('dhis2-uicore-splitbutton-menu')).toBeInTheDocument()

fireEvent.keyDown(document, { key: ' ' })

// Use waitFor to wait for the DOM to update
await waitFor(() => {
expect(
getByTestId('dhis2-uicore-splitbutton-menu')
).toBeInTheDocument()
})
})

it('closes dropdown when escape key is pressed', async () => {
const { getByTestId, queryByTestId } = render(
<SplitButton component={<div>Dropdown Content</div>} />
Expand Down

0 comments on commit e1400a3

Please sign in to comment.