Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add SocialIcon unit tests #936

Closed
Closed
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
0ddc957
test: add unit tests for SocialIcon component
devin-ai-integration[bot] Jan 28, 2025
6892469
test: improve SocialIcon test coverage for hover states and transitions
devin-ai-integration[bot] Jan 28, 2025
95a6769
fix: add missing closing brace in SocialIcon test
devin-ai-integration[bot] Jan 28, 2025
459e8f4
test: add test case for SocialIcon without ColoredIcon prop
devin-ai-integration[bot] Jan 28, 2025
0fbc3a2
test: add test case for transition styles
devin-ai-integration[bot] Jan 28, 2025
1f66ef5
test: fix style assertions in SocialIcon tests
devin-ai-integration[bot] Jan 28, 2025
52a7b59
test: improve SocialIcon test coverage with style and hover assertions
devin-ai-integration[bot] Jan 28, 2025
9e2303c
test: update style assertions to match testing library expectations
devin-ai-integration[bot] Jan 28, 2025
c81decd
test: update style assertions to use object format consistently
devin-ai-integration[bot] Jan 28, 2025
d1d4e07
test: update style assertions to use string values for opacity and th…
devin-ai-integration[bot] Jan 28, 2025
1beb6e5
test: update style assertions with complete style properties
devin-ai-integration[bot] Jan 28, 2025
efae99d
test: add theme-based style assertions for width and height
devin-ai-integration[bot] Jan 28, 2025
4f05fbb
test: add comprehensive hover state transition tests
devin-ai-integration[bot] Jan 28, 2025
6321771
test: update style assertions to use individual checks and RGB values
devin-ai-integration[bot] Jan 28, 2025
e345eff
test: update remaining style assertions to use individual checks and …
devin-ai-integration[bot] Jan 28, 2025
2790319
test: add key prop and component type assertions
devin-ai-integration[bot] Jan 28, 2025
a2000fc
test: add test case for undefined color behavior
devin-ai-integration[bot] Jan 28, 2025
fe249d2
test: add comprehensive style assertions for StyledColoredIcon
devin-ai-integration[bot] Jan 28, 2025
4754f72
test: add additional test cases for theme spacing and transitions
devin-ai-integration[bot] Jan 28, 2025
524c26b
test: update style assertions to use toHaveAttribute with stringConta…
devin-ai-integration[bot] Jan 28, 2025
2b2c9e0
test: update remaining style assertions to use toHaveStyle
devin-ai-integration[bot] Jan 29, 2025
ee08844
test: update style assertions to use theme values and consistent obje…
devin-ai-integration[bot] Jan 29, 2025
02370a8
test: update remaining style assertions to use theme values
devin-ai-integration[bot] Jan 29, 2025
7710336
test: update remaining style assertions to use getComputedStyle
devin-ai-integration[bot] Jan 29, 2025
7de8c34
test: add transition timing assertions
devin-ai-integration[bot] Jan 29, 2025
e64dad6
test: update style assertions to use toHaveStyle for more reliable te…
devin-ai-integration[bot] Jan 29, 2025
582c0f2
test: update remaining style assertions to use toHaveStyle
devin-ai-integration[bot] Jan 29, 2025
7dc2a74
test: update remaining style assertions to use toHaveStyle consistently
devin-ai-integration[bot] Jan 29, 2025
c03681d
test: update coverage configuration with thresholds and reporters
devin-ai-integration[bot] Jan 29, 2025
1d9f2c4
test: add lcov reporter and coverage directory configuration
devin-ai-integration[bot] Jan 29, 2025
707f9f0
test: update style assertions to target correct styled components
devin-ai-integration[bot] Jan 29, 2025
1472600
test: add sonar coverage reporter and improve coverage configuration
devin-ai-integration[bot] Jan 29, 2025
3f38879
chore: add sonar-project.properties for coverage reporting
devin-ai-integration[bot] Jan 29, 2025
692424b
ci: add SonarCloud coverage reporting step
devin-ai-integration[bot] Jan 29, 2025
8c3e5dc
ci: update SonarCloud configuration for better coverage reporting
devin-ai-integration[bot] Jan 29, 2025
ca4a1d6
ci: update coverage reporting with v4 upload-artifact
devin-ai-integration[bot] Jan 29, 2025
367450f
ci: fix coverage path handling for SonarCloud
devin-ai-integration[bot] Jan 29, 2025
720969f
test: update style assertions to use getComputedStyle instead of toHa…
devin-ai-integration[bot] Jan 29, 2025
4c88b0c
test: update style assertions to use getComputedStyle with comprehens…
devin-ai-integration[bot] Jan 29, 2025
6dbf07c
ci: improve coverage artifact handling and path fixing for SonarCloud
devin-ai-integration[bot] Jan 29, 2025
1440c02
ci: improve coverage configuration and reporting
devin-ai-integration[bot] Jan 29, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
test: update style assertions to use theme values and consistent obje…
…ct format

Co-Authored-By: Leon Talbert <[email protected]>
devin-ai-integration[bot] and LeonmanRolls committed Jan 29, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit ee0884490b6bd71b1d20ecbee36843ad09bd1212
67 changes: 43 additions & 24 deletions src/components/SocialIcon.test.tsx
Original file line number Diff line number Diff line change
@@ -20,7 +20,9 @@
expect(icon).toBeInTheDocument()
expect(link).toHaveAttribute('href', 'https://example.com')
expect(link).toHaveAttribute('target', '_blank')
expect(link).toHaveStyle('color: rgb(161, 161, 161)')
expect(link).toHaveStyle({
color: theme.colors.greyPrimary

Check failure on line 24 in src/components/SocialIcon.test.tsx

GitHub Actions / coverage

src/components/SocialIcon.test.tsx > SocialIcon > should render icon and external link with correct attributes

ReferenceError: theme is not defined ❯ src/components/SocialIcon.test.tsx:24:14
})
})

it('should render and handle colored icon correctly with proper component rendering', () => {
@@ -38,7 +40,7 @@
expect(defaultIcon).toBeInTheDocument()
expect(coloredIcon).toBeInTheDocument()
const coloredIconWrapper = coloredIcon.parentElement?.parentElement
expect(coloredIconWrapper).toHaveStyle({

Check failure on line 43 in src/components/SocialIcon.test.tsx

GitHub Actions / coverage

src/components/SocialIcon.test.tsx > SocialIcon > should render and handle colored icon correctly with proper component rendering

Error: expect(element).toHaveStyle() - Expected + Received - height: 100%; - opacity: 0; - position: absolute; - transition: 0.15s all ease-in-out; ❯ src/components/SocialIcon.test.tsx:43:32
opacity: '0',
height: '100%',
position: 'absolute',
@@ -78,8 +80,8 @@
expect(defaultIcon).toHaveStyle({
position: 'absolute',
height: '100%',
transition: '0.15s all ease-in-out',
fill: 'rgb(161, 161, 161)'
fill: theme.colors.greyPrimary,

Check failure on line 83 in src/components/SocialIcon.test.tsx

GitHub Actions / coverage

src/components/SocialIcon.test.tsx > SocialIcon > should handle hover states correctly

ReferenceError: theme is not defined ❯ src/components/SocialIcon.test.tsx:83:13
transition: '0.15s all ease-in-out'
})

await userEvent.unhover(link)
@@ -100,9 +102,9 @@
const coloredIcon = screen.getByTestId('mock-colored-icon')
const coloredIconWrapper = coloredIcon.parentElement?.parentElement

expect(coloredIconWrapper).toHaveStyle('opacity: 0')
expect(coloredIconWrapper).toHaveStyle({ opacity: '0' })

Check failure on line 105 in src/components/SocialIcon.test.tsx

GitHub Actions / coverage

src/components/SocialIcon.test.tsx > SocialIcon > should show colored icon on hover when ColoredIcon is provided

Error: expect(element).toHaveStyle() - Expected + Received - opacity: 0; ❯ src/components/SocialIcon.test.tsx:105:32
await userEvent.hover(link)
expect(coloredIconWrapper).toHaveStyle('opacity: 1')
expect(coloredIconWrapper).toHaveStyle({ opacity: '1' })
})

it('should change icon color on hover when color prop is provided', async () => {
@@ -118,15 +120,12 @@
const icon = screen.getByTestId('mock-icon')

expect(link).toHaveStyle({
color: 'rgb(161, 161, 161)',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
position: 'relative',
cursor: 'pointer'
})
await userEvent.hover(link)
expect(link).toHaveStyle(`color: ${customColor}`)

Check failure on line 128 in src/components/SocialIcon.test.tsx

GitHub Actions / coverage

src/components/SocialIcon.test.tsx > SocialIcon > should change icon color on hover when color prop is provided

Error: expect(element).toHaveStyle() - Expected + Received - color: rgb(255, 0, 0); ❯ src/components/SocialIcon.test.tsx:128:18
})

it('should render without ColoredIcon prop', () => {
@@ -157,7 +156,9 @@
alignItems: 'center',
justifyContent: 'center'
})
expect(icon).toHaveStyle('transition: 0.15s all ease-in-out')
expect(icon).toHaveStyle({

Check failure on line 159 in src/components/SocialIcon.test.tsx

GitHub Actions / coverage

src/components/SocialIcon.test.tsx > SocialIcon > should have correct transition styles

Error: expect(element).toHaveStyle() - Expected + Received - transition: 0.15s all ease-in-out; ❯ src/components/SocialIcon.test.tsx:159:18
transition: '0.15s all ease-in-out'
})
})

it('should have correct default styles and props', () => {
@@ -171,13 +172,17 @@
const icon = screen.getByTestId('mock-icon')

// Test SocialIconWrapper styles
expect(link).toHaveAttribute('style', expect.stringContaining('display: flex'))
expect(link).toHaveAttribute('style', expect.stringContaining('align-items: center'))
expect(link).toHaveAttribute('style', expect.stringContaining('justify-content: center'))
expect(link).toHaveAttribute('style', expect.stringContaining('position: relative'))
expect(link).toHaveAttribute('style', expect.stringContaining('cursor: pointer'))
expect(link).toHaveStyle({
width: '1.5rem',
display: 'flex',
alignItems: 'center',
justifyContent: 'center',
width: theme.space['6'],

Check failure on line 179 in src/components/SocialIcon.test.tsx

GitHub Actions / coverage

src/components/SocialIcon.test.tsx > SocialIcon > should have correct default styles and props

ReferenceError: theme is not defined ❯ src/components/SocialIcon.test.tsx:179:14
minHeight: theme.space['6']
})
expect(link).toHaveStyle({
position: 'relative',
cursor: 'pointer',
width: theme.space['6'],
minHeight: '1.5rem'
})
expect(link).toHaveAttribute('target', '_blank')
@@ -206,7 +211,7 @@
const coloredIcon = screen.getByTestId('mock-colored-icon')
const coloredIconWrapper = coloredIcon.parentElement?.parentElement

expect(coloredIconWrapper).toHaveStyle({

Check failure on line 214 in src/components/SocialIcon.test.tsx

GitHub Actions / coverage

src/components/SocialIcon.test.tsx > SocialIcon > should have correct styles for StyledColoredIcon

Error: expect(element).toHaveStyle() - Expected + Received - height: 100%; - opacity: 0; - position: absolute; - transition: 0.15s all ease-in-out; ❯ src/components/SocialIcon.test.tsx:214:32
height: '100%',
position: 'absolute',
transition: '0.15s all ease-in-out',
@@ -226,7 +231,7 @@
const icon = screen.getByTestId('mock-icon')
const link = screen.getByRole('link')

expect(icon).toHaveStyle({

Check failure on line 234 in src/components/SocialIcon.test.tsx

GitHub Actions / coverage

src/components/SocialIcon.test.tsx > SocialIcon > should apply custom color on hover

Error: expect(element).toHaveStyle() - Expected + Received - fill: rgb(161, 161, 161); - height: 100%; - position: absolute; - transition: 0.15s all ease-in-out; ❯ src/components/SocialIcon.test.tsx:234:18
position: 'absolute',
height: '100%',
transition: '0.15s all ease-in-out',
@@ -251,11 +256,17 @@
const link = screen.getByRole('link')
const coloredIconWrapper = coloredIcon.parentElement?.parentElement

expect(defaultIcon).toHaveStyle('fill: rgb(161, 161, 161)')
expect(coloredIconWrapper).toHaveStyle('opacity: 0')
expect(defaultIcon).toHaveStyle({
fill: theme.colors.greyPrimary

Check failure on line 260 in src/components/SocialIcon.test.tsx

GitHub Actions / coverage

src/components/SocialIcon.test.tsx > SocialIcon > should handle hover state transitions for both icons

ReferenceError: theme is not defined ❯ src/components/SocialIcon.test.tsx:260:13
})
expect(coloredIconWrapper).toHaveStyle({
opacity: '0'
})

await userEvent.hover(link)
expect(defaultIcon).toHaveStyle(`fill: ${customColor}`)
expect(defaultIcon).toHaveStyle({
fill: customColor
})
expect(coloredIconWrapper).toHaveStyle('opacity: 1')

await userEvent.unhover(link)
@@ -281,12 +292,16 @@
})

await userEvent.hover(link)
expect(defaultIcon).toHaveAttribute('style', expect.stringContaining('fill: rgb(161, 161, 161)'))
expect(defaultIcon).toHaveAttribute('style', expect.stringContaining('transition: 0.15s all ease-in-out'))
expect(defaultIcon).toHaveStyle({
fill: theme.colors.greyPrimary,
transition: '0.15s all ease-in-out'
})

await userEvent.unhover(link)
expect(defaultIcon).toHaveAttribute('style', expect.stringContaining('fill: rgb(161, 161, 161)'))
expect(defaultIcon).toHaveAttribute('style', expect.stringContaining('transition: 0.15s all ease-in-out'))
expect(defaultIcon).toHaveStyle({
fill: theme.colors.greyPrimary,
transition: '0.15s all ease-in-out'
})
})

it('should verify theme-based spacing for width and height', () => {
@@ -315,8 +330,12 @@
const coloredIcon = screen.getByTestId('mock-colored-icon')
const coloredIconWrapper = coloredIcon.parentElement?.parentElement

expect(defaultIcon).toHaveStyle('transition: 0.15s all ease-in-out')
expect(coloredIconWrapper).toHaveStyle('transition: 0.15s all ease-in-out')
expect(defaultIcon).toHaveStyle({
transition: '0.15s all ease-in-out'
})
expect(coloredIconWrapper).toHaveStyle({
transition: '0.15s all ease-in-out'
})
})

it('should handle required props correctly', () => {