✅ test(Projects): fix failing tests

This commit is contained in:
2025-05-23 14:22:57 +00:00
parent 35dbb03a8c
commit 3e2146cf2a
@@ -1,12 +1,9 @@
import { screen } from '@testing-library/react' import { screen } from '@testing-library/react'
import userEvent from '@testing-library/user-event'
import { renderWithRouter as render } from 'components/utils/tests'
import { renderWithRouter as render } from 'components/utils/tests/index.js'
import ProjectsPage from '.' import ProjectsPage from '.'
vi.stubGlobal('open', vi.fn()) vi.stubGlobal('open', vi.fn())
const open = vi.spyOn(window, 'open')
describe('ProjectsPage component', () => { describe('ProjectsPage component', () => {
test('renders without crashing and displays the correct project titles', () => { test('renders without crashing and displays the correct project titles', () => {
render(<ProjectsPage />) render(<ProjectsPage />)
@@ -25,8 +22,10 @@ describe('ProjectsPage component', () => {
test('opens the correct links when the link buttons are clicked', async () => { test('opens the correct links when the link buttons are clicked', async () => {
render(<ProjectsPage />) render(<ProjectsPage />)
// test one of the many links // inspect one of the many links
await userEvent.click(screen.getByLabelText('Video-button')) const link = screen.getByLabelText('Video-button')
expect(open).toHaveBeenLastCalledWith('https://www.linkedin.com/feed/update/urn:li:activity:7034480841569284096/', '_blank') expect(link).toHaveAttribute('href', 'https://www.linkedin.com/feed/update/urn:li:activity:7034480841569284096/')
expect(link).toHaveAttribute('target', '_blank')
expect(link).toHaveAttribute('rel', 'noopener noreferrer')
}) })
}) })