1
+ import CommunityStats , { stats } from "@/components/sections/homepage/_partials/testimonials/CommunityStats" ;
2
+ import "@testing-library/jest-dom" ;
3
+ import { screen } from "@testing-library/react" ;
4
+ import { renderWithRedux } from "../../../../../__mocks__/renderWithRedux" ;
5
+
6
+ describe ( "CommunityStats" , ( ) => {
7
+ it ( "should render Community stats" , ( ) => {
8
+ renderWithRedux ( < CommunityStats testId = "communityStatsId" /> )
9
+ const communityStat = screen . getByTestId ( "communityStatsId" )
10
+ expect ( communityStat ) . toBeInTheDocument ( )
11
+ } )
12
+
13
+ it ( "should display the stats" , ( ) => {
14
+ renderWithRedux ( < CommunityStats /> )
15
+ stats . forEach ( ( stat ) => {
16
+ expect ( screen . getByText ( stat . count ) ) . toBeInTheDocument ( )
17
+ expect ( screen . getByText ( stat . count ) . textContent ) . toBe ( ( stat . count ) . toString ( ) )
18
+ expect ( screen . getByText ( stat . title ) ) . toBeInTheDocument ( )
19
+ expect ( screen . getByText ( stat . title ) . textContent ) . toBe ( ( stat . title ) . toString ( ) )
20
+ expect ( screen . getByText ( stat . description ) ) . toBeInTheDocument ( )
21
+ expect ( screen . getByText ( stat . description ) . textContent ) . toBe ( ( stat . title + ( " " ) + stat . description ) . toString ( ) )
22
+ } )
23
+ } )
24
+
25
+ it ( "should display the anchor tag with button" , ( ) => {
26
+ renderWithRedux ( < CommunityStats /> )
27
+ expect ( screen . getByRole ( "link" ) ) . toHaveAttribute ( "href" ) ;
28
+ expect ( screen . getByRole ( "link" ) . getAttribute ( "href" ) ) . toBe ( "https://discord.gg/U38KQHDtHe" ) ;
29
+ expect ( screen . getByRole ( "button" ) ) . toBeInTheDocument ( )
30
+ expect ( screen . getByText ( "testimonials.community.join" ) ) . toBeInTheDocument ( )
31
+ } )
32
+ } )
0 commit comments