Skip to content

Commit

Permalink
2548: Refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
LeandraH committed Dec 2, 2024
1 parent 4b87183 commit 20fded0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions web/src/components/CityContentToolbar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { useTheme } from 'styled-components'
import { CopyIcon, DoneIcon } from '../assets'
import useWindowDimensions from '../hooks/useWindowDimensions'
import { RouteType } from '../routes'
import FeedbackToolbarItem from './FeedbackToolbarItem'
import FeedbackToolbarIcons from './FeedbackToolbarIcons'
import SharingPopup from './SharingPopup'
import Toolbar from './Toolbar'
import ToolbarItem from './ToolbarItem'
Expand Down Expand Up @@ -73,7 +73,7 @@ const CityContentToolbar = (props: CityContentToolbarProps) => {
id='copy-icon'
/>
</Tooltip>
{hasFeedbackOption && <FeedbackToolbarItem route={route} slug={feedbackTarget} />}
{hasFeedbackOption && <FeedbackToolbarIcons route={route} slug={feedbackTarget} />}
</Toolbar>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ import FeedbackContainer from './FeedbackContainer'
import Modal from './Modal'
import ToolbarItem from './ToolbarItem'

type FeedbackToolbarItemProps = {
type FeedbackToolbarIconsProps = {
route: RouteType
slug?: string
}

const FeedbackToolbarItem = ({ route, slug }: FeedbackToolbarItemProps): ReactElement => {
const FeedbackToolbarIcons = ({ route, slug }: FeedbackToolbarIconsProps): ReactElement => {
const { cityCode, languageCode } = useCityContentParams()
const [isFeedbackOpen, setIsFeedbackOpen] = useState(false)
const [isSubmitted, setIsSubmitted] = useState(false)
Expand Down Expand Up @@ -59,4 +59,4 @@ const FeedbackToolbarItem = ({ route, slug }: FeedbackToolbarItemProps): ReactEl
)
}

export default FeedbackToolbarItem
export default FeedbackToolbarIcons
6 changes: 3 additions & 3 deletions web/src/components/__tests__/FeedbackToolbarItem.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import React, { ReactElement } from 'react'
import { CATEGORIES_ROUTE } from 'shared'

import { renderWithRouterAndTheme } from '../../testing/render'
import FeedbackToolbarItem from '../FeedbackToolbarItem'
import FeedbackToolbarIcons from '../FeedbackToolbarIcons'

jest.mock('react-i18next')
jest.mock('shared/api', () => ({
Expand All @@ -15,10 +15,10 @@ jest.mock('shared/api', () => ({
}))
jest.mock('focus-trap-react', () => ({ children }: { children: ReactElement }) => <div>{children}</div>)

describe('FeedbackToolbarItem', () => {
describe('FeedbackToolbarIcons', () => {
it('should open and update title on submit feedback', async () => {
const { queryByText, findByText, getByText } = renderWithRouterAndTheme(
<FeedbackToolbarItem route={CATEGORIES_ROUTE} slug='my-slug' />,
<FeedbackToolbarIcons route={CATEGORIES_ROUTE} slug='my-slug' />,
)

expect(queryByText('feedback:headline')).toBeFalsy()
Expand Down

0 comments on commit 20fded0

Please sign in to comment.