Skip to content

Commit

Permalink
test: update remaining style assertions to use toHaveStyle consistently
Browse files Browse the repository at this point in the history
Co-Authored-By: Leon Talbert <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and LeonmanRolls committed Jan 29, 2025
1 parent 582c0f2 commit 7dc2a74
Showing 1 changed file with 27 additions and 20 deletions.
47 changes: 27 additions & 20 deletions src/components/SocialIcon.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ describe('SocialIcon', () => {
expect(defaultIcon).toBeInTheDocument()
expect(coloredIcon).toBeInTheDocument()
const coloredIconWrapper = coloredIcon.parentElement?.parentElement
const computedStyles = window.getComputedStyle(coloredIconWrapper!)
expect(coloredIconWrapper).toHaveStyle({

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

View workflow job for this annotation

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:44:32
height: '100%',
position: 'absolute',
Expand Down Expand Up @@ -237,14 +236,16 @@ describe('SocialIcon', () => {
const icon = screen.getByTestId('mock-icon')
const link = screen.getByRole('link')

const initialIconStyles = window.getComputedStyle(icon)
expect(initialIconStyles.position).toBe('absolute')
expect(initialIconStyles.height).toBe('100%')
expect(initialIconStyles.fill).toBe('hsl(240 6% 63%)')
expect(icon.parentElement).toHaveStyle({

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

View workflow job for this annotation

GitHub Actions / coverage

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

Error: expect(element).toHaveStyle() - Expected + Received - fill: hsl(240 6% 63%); - height: 100%; - position: absolute; + position: relative; ❯ src/components/SocialIcon.test.tsx:239:32
position: 'absolute',
height: '100%',
fill: lightTheme.colors.greyPrimary
})

await userEvent.hover(link)
const hoverIconStyles = window.getComputedStyle(icon)
expect(hoverIconStyles.fill).toBe(customColor)
expect(icon.parentElement).toHaveStyle({
fill: customColor
})
})

it('should handle hover state transitions for both icons', async () => {
Expand All @@ -262,24 +263,29 @@ describe('SocialIcon', () => {
const link = screen.getByRole('link')
const coloredIconWrapper = coloredIcon.parentElement?.parentElement

const initialIconStyles = window.getComputedStyle(defaultIcon)
expect(initialIconStyles.fill).toBe(lightTheme.colors.greyPrimary)
const initialWrapperStyles = window.getComputedStyle(coloredIconWrapper!)
expect(initialWrapperStyles.opacity).toBe('0')
expect(defaultIcon.parentElement).toHaveStyle({

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

View workflow job for this annotation

GitHub Actions / coverage

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

Error: expect(element).toHaveStyle() - Expected + Received - fill: hsl(240 6% 63%); ❯ src/components/SocialIcon.test.tsx:266:39
fill: lightTheme.colors.greyPrimary
})
expect(coloredIconWrapper).toHaveStyle({
opacity: '0'
})

await userEvent.hover(link)
expect(defaultIcon.parentElement).toHaveStyle({
fill: customColor,
transition: '0.15s all ease-in-out'
})
const hoverWrapperStyles = window.getComputedStyle(coloredIconWrapper!)
expect(hoverWrapperStyles.opacity).toBe('1')
expect(coloredIconWrapper).toHaveStyle({
opacity: '1'
})

await userEvent.unhover(link)
const unhoverIconStyles = window.getComputedStyle(defaultIcon)
expect(unhoverIconStyles.fill).toBe('rgb(161, 161, 161)')
const unhoverWrapperStyles = window.getComputedStyle(coloredIconWrapper!)
expect(unhoverWrapperStyles.opacity).toBe('0')
expect(defaultIcon.parentElement).toHaveStyle({
fill: lightTheme.colors.greyPrimary
})
expect(coloredIconWrapper).toHaveStyle({
opacity: '0'
})
})

it('should maintain default fill color on hover when no custom color is provided', async () => {
Expand Down Expand Up @@ -318,9 +324,10 @@ describe('SocialIcon', () => {
/>,
)
const link = screen.getByRole('link')
const computedLinkStyles = window.getComputedStyle(link)
expect(computedLinkStyles.width).toBe(lightTheme.space['6'])
expect(computedLinkStyles.minHeight).toBe(lightTheme.space['6'])
expect(link).toHaveStyle({
width: lightTheme.space['6'],
minHeight: lightTheme.space['6']
})
})

it('should verify transition timing for all styled components', () => {
Expand Down

0 comments on commit 7dc2a74

Please sign in to comment.