Skip to content

Commit 478c393

Browse files
committed
Fix make check and revert unnecessary changes
1 parent 01ec661 commit 478c393

File tree

3 files changed

+61
-52
lines changed

3 files changed

+61
-52
lines changed

cspell/custom-dict.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ slackbot
114114
slideshare
115115
speakerdeck
116116
superfences
117+
svgs
117118
tiktok
118119
tsc
119120
turbopack
Lines changed: 60 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,73 +1,82 @@
1-
import { render, screen } from '@testing-library/react';
1+
import { IconProp } from '@fortawesome/fontawesome-svg-core'
2+
import { faCertificate } from '@fortawesome/free-solid-svg-icons'
3+
import { render, screen } from '@testing-library/react'
4+
import React from 'react'
25

3-
import '@testing-library/jest-dom';
4-
import { faCertificate } from '@fortawesome/free-solid-svg-icons';
6+
import '@testing-library/jest-dom'
57

6-
import GeneralCompliantComponent from '../../../src/components/GeneralCompliantComponent';
8+
// Mock the Tooltip component to prevent async state update warnings
9+
jest.mock('@heroui/tooltip', () => ({
10+
Tooltip: ({ children, content }: { children: React.ReactNode; content: string }) => (
11+
<div data-testid="tooltip" title={content}>
12+
{children}
13+
</div>
14+
),
15+
}))
16+
17+
import GeneralCompliantComponent from 'components/GeneralCompliantComponent'
718

819
type GeneralCompliantComponentProps = {
9-
compliant: boolean;
10-
icon: any;
11-
title: string;
12-
};
20+
compliant: boolean
21+
icon: IconProp
22+
title: string
23+
}
1324

1425
describe('GeneralCompliantComponent', () => {
1526
const baseProps: GeneralCompliantComponentProps = {
1627
compliant: true,
1728
icon: faCertificate,
1829
title: 'Test Title',
19-
};
30+
}
2031

2132
it('renders successfully with minimal required props', () => {
22-
render(<GeneralCompliantComponent {...baseProps} />);
23-
expect(screen.getByText('Test Title')).toBeInTheDocument();
24-
});
33+
const { container } = render(<GeneralCompliantComponent {...baseProps} />)
34+
expect(container).toBeInTheDocument()
35+
})
2536

26-
it('applies correct color for compliant=true', () => {
27-
const { container } = render(<GeneralCompliantComponent {...baseProps} compliant={true} />);
28-
const svg = container.querySelector('svg'); // Find the SVG icon
29-
expect(svg).toBeInTheDocument();
30-
expect(svg).toHaveClass('text-green-400/80'); // Check for the specific class
31-
});
37+
it('applies correct color for compliant=true', () => {
38+
const { container } = render(<GeneralCompliantComponent {...baseProps} compliant={true} />)
39+
const svg = container.querySelector('svg')
40+
expect(svg).toBeInTheDocument()
41+
expect(svg).toHaveClass('text-green-400/80')
42+
})
3243

3344
it('applies correct color for compliant=false', () => {
34-
const { container } = render(<GeneralCompliantComponent {...baseProps} compliant={false} />);
35-
const svg = container.querySelector('svg'); // Find the SVG icon
36-
expect(svg).toBeInTheDocument();
37-
expect(svg).toHaveClass('text-red-400/80'); // Check for the specific class
38-
});
45+
const { container } = render(<GeneralCompliantComponent {...baseProps} compliant={false} />)
46+
const svg = container.querySelector('svg')
47+
expect(svg).toBeInTheDocument()
48+
expect(svg).toHaveClass('text-red-400/80')
49+
})
3950

40-
it('renders the correct icon and title', () => {
41-
render(<GeneralCompliantComponent {...baseProps} title="My Title" />);
42-
expect(screen.getByText('My Title')).toBeInTheDocument();
43-
});
51+
it('renders the correct icon structure', () => {
52+
const { container } = render(<GeneralCompliantComponent {...baseProps} />)
53+
const svgs = container.querySelectorAll('svg')
54+
expect(svgs).toHaveLength(2)
55+
})
4456

45-
it('renders tooltip with the title', () => {
46-
const { getByText } = render(<GeneralCompliantComponent {...baseProps} title="Tooltip Title" />);
47-
// Tooltip content is rendered, but may require hover simulation in real DOM
48-
expect(getByText('Tooltip Title')).toBeInTheDocument();
49-
});
57+
it('renders tooltip wrapper with title attribute', () => {
58+
render(<GeneralCompliantComponent {...baseProps} title="Tooltip Title" />)
59+
const tooltip = screen.getByTestId('tooltip')
60+
expect(tooltip).toBeInTheDocument()
61+
expect(tooltip).toHaveAttribute('title', 'Tooltip Title')
62+
})
5063

5164
it('handles edge case: empty title', () => {
52-
const { container } = render(<GeneralCompliantComponent {...baseProps} title="" />);
53-
expect(container).toBeInTheDocument();
54-
});
65+
const { container } = render(<GeneralCompliantComponent {...baseProps} title="" />)
66+
expect(container).toBeInTheDocument()
67+
})
5568

56-
it('has accessible role and label', () => {
57-
render(<GeneralCompliantComponent {...baseProps} />);
58-
const iconElement = screen.getByText(baseProps.title); // Asserts the title text is visible
59-
expect(iconElement).toBeInTheDocument();
60-
// Or, if the icon has a specific role, you can check for that
61-
// expect(screen.getByRole('img', { hidden: true })).toBeInTheDocument();
62-
});
69+
it('has accessible SVG icons', () => {
70+
const { container } = render(<GeneralCompliantComponent {...baseProps} />)
71+
const svgs = container.querySelectorAll('svg[role="img"]')
72+
expect(svgs).toHaveLength(2)
73+
expect(svgs[0]).toHaveAttribute('aria-hidden', 'true')
74+
expect(svgs[1]).toHaveAttribute('aria-hidden', 'true')
75+
})
6376

6477
it('renders with custom icon', () => {
65-
const customIcon = faCertificate; // Replace with another icon if needed
66-
const { container } = render(<GeneralCompliantComponent {...baseProps} icon={customIcon} />);
67-
expect(container.querySelector('svg')).toBeInTheDocument();
68-
});
69-
70-
// Add more tests as needed for event handling, state, etc.
71-
});
72-
73-
// ...existing code...
78+
const customIcon = faCertificate
79+
const { container } = render(<GeneralCompliantComponent {...baseProps} icon={customIcon} />)
80+
expect(container.querySelector('svg')).toBeInTheDocument()
81+
})
82+
})

frontend/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,6 @@
7070
"@swc/core": "^1.13.3",
7171
"@swc/jest": "^0.2.39",
7272
"@tailwindcss/postcss": "^4.1.11",
73-
"@testing-library/dom": "^10.4.1",
7473
"@testing-library/jest-dom": "^6.6.4",
7574
"@testing-library/react": "^16.3.0",
7675
"@types/jest": "^29.5.14",

0 commit comments

Comments
 (0)