Skip to content

Commit 2a08a64

Browse files
committed
Changes has been made so that it works with eslint
1 parent 7e1620c commit 2a08a64

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

frontend/__tests__/unit/pages/ProjectDashboredDropDown.test.tsx

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
import React from 'react'
1+
import { faFilter, faSort } from '@fortawesome/free-solid-svg-icons'
22
import { render, screen, fireEvent } from '@testing-library/react'
3+
import React from 'react'
34
import ProjectsDashboardDropDown from 'components/ProjectsDashboardDropDown'
4-
import { faFilter, faSort } from '@fortawesome/free-solid-svg-icons'
55

66
// Mock FontAwesome components
77
jest.mock('@fortawesome/react-fontawesome', () => ({
8-
FontAwesomeIcon: ({ icon, ...props }: any) => (
8+
FontAwesomeIcon: ({ icon, ...props }: { icon?: { iconName?: string }; [key: string]: unknown }) => (
99
<span
1010
data-testid="font-awesome-icon"
1111
data-icon={icon?.iconName || 'default'}
@@ -97,6 +97,7 @@ jest.mock('@heroui/react', () => ({
9797
Button: ({ children, variant, ...props }: {
9898
children: React.ReactNode
9999
variant?: string
100+
[key: string]: unknown
100101
}) => (
101102
<button
102103
data-testid="dropdown-button"
@@ -307,12 +308,12 @@ describe('ProjectsDashboardDropDown Component', () => {
307308

308309
const items = screen.getAllByTestId('dropdown-item')
309310
const activeItem = items.find(item => item.textContent === 'Active')
311+
312+
// Use non-conditional expect
310313
expect(activeItem).toBeDefined()
311-
312-
if (activeItem) {
313-
fireEvent.click(activeItem)
314-
expect(mockOnAction).toHaveBeenCalledWith('Active')
315-
}
314+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
315+
fireEvent.click(activeItem!)
316+
expect(mockOnAction).toHaveBeenCalledWith('Active')
316317
})
317318

318319
it('calls onAction when dropdown item is activated with keyboard', () => {
@@ -326,12 +327,11 @@ describe('ProjectsDashboardDropDown Component', () => {
326327

327328
const items = screen.getAllByTestId('dropdown-item')
328329
const activeItem = items.find(item => item.textContent === 'Active')
330+
329331
expect(activeItem).toBeDefined()
330-
331-
if (activeItem) {
332-
fireEvent.keyDown(activeItem, { key: 'Enter' })
333-
expect(mockOnAction).toHaveBeenCalledWith('Active')
334-
}
332+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
333+
fireEvent.keyDown(activeItem!, { key: 'Enter' })
334+
expect(mockOnAction).toHaveBeenCalledWith('Active')
335335
})
336336

337337
it('handles multiple clicks correctly', () => {
@@ -349,15 +349,15 @@ describe('ProjectsDashboardDropDown Component', () => {
349349

350350
expect(activeItem).toBeDefined()
351351
expect(inactiveItem).toBeDefined()
352+
353+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
354+
fireEvent.click(activeItem!)
355+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
356+
fireEvent.click(inactiveItem!)
352357

353-
if (activeItem && inactiveItem) {
354-
fireEvent.click(activeItem)
355-
fireEvent.click(inactiveItem)
356-
357-
expect(mockOnAction).toHaveBeenCalledTimes(2)
358-
expect(mockOnAction).toHaveBeenCalledWith('Active')
359-
expect(mockOnAction).toHaveBeenCalledWith('Inactive')
360-
}
358+
expect(mockOnAction).toHaveBeenCalledTimes(2)
359+
expect(mockOnAction).toHaveBeenCalledWith('Active')
360+
expect(mockOnAction).toHaveBeenCalledWith('Inactive')
361361
})
362362
})
363363

@@ -657,4 +657,4 @@ describe('ProjectsDashboardDropDown Component', () => {
657657
expect(flexContainer).toHaveClass('flex', 'flex-col', 'items-center')
658658
})
659659
})
660-
})
660+
})

0 commit comments

Comments
 (0)