-
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* refactor: 567 - change styles to modules * refactor: 567 - change class names and replace tag selectors * refactor: 567 - add semantic tags * refactor: 567 - add descriptive alt attribute * refactor: 567 - move test file to the ui folder * refactor: 567 - update tests * refactor: 567 - change styles * refactor: 567 - change data-testid
- Loading branch information
Showing
4 changed files
with
74 additions
and
64 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { screen } from '@testing-library/react'; | ||
import { describe, expect, it } from 'vitest'; | ||
import { Support } from './support'; | ||
import { renderWithRouter } from '@/shared/__tests__/utils'; | ||
import supportImg from '@/shared/assets/support.webp'; | ||
|
||
describe('Support Component', () => { | ||
const mockedData = { | ||
titleText: 'Support Us', | ||
firstParagraphText: | ||
/Your donations help us cover hosting, domains, licenses, and advertising for courses and events./i, | ||
secondParagraphText: 'Thank you for your support!', | ||
href: 'https://opencollective.com/rsschool', | ||
image: supportImg, | ||
alt: 'A sloth mascot with a piggy bank in his hands', | ||
}; | ||
|
||
const { titleText, firstParagraphText, secondParagraphText, href, image, alt } = mockedData; | ||
|
||
it('renders the component content correctly', () => { | ||
renderWithRouter(<Support />); | ||
const supportSection = screen.getByTestId('support-section'); | ||
const title = screen.getByTestId('widget-title'); | ||
const paragraphs = screen.getAllByTestId('paragraph'); | ||
const link = screen.getByTestId('link-support'); | ||
const slothImage = screen.getByTestId('sloth-mascot'); | ||
|
||
expect(supportSection).toBeVisible(); | ||
expect(title).toBeVisible(); | ||
paragraphs.forEach((paragraph) => { | ||
expect(paragraph).toBeVisible(); | ||
}); | ||
expect(link).toBeVisible(); | ||
expect(slothImage).toBeVisible(); | ||
|
||
expect(title).toHaveTextContent(titleText); | ||
expect(paragraphs[0]).toHaveTextContent(firstParagraphText); | ||
expect(paragraphs[1]).toHaveTextContent(secondParagraphText); | ||
|
||
expect(link).toHaveAttribute('href', href); | ||
expect(slothImage).toHaveAttribute('src', image.src); | ||
expect(slothImage).toHaveAttribute('alt', alt); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters