-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #49 from joshuaow91/WEB-21
chore: added unit test for cards sections to verify correct content i…
- Loading branch information
Showing
2 changed files
with
42 additions
and
7 deletions.
There are no files selected for viewing
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,42 @@ | ||
import { render, screen } from '@testing-library/react'; | ||
import CardsSection from './CardsSection'; | ||
|
||
describe('CardsSection', () => { | ||
const labelMock = { | ||
lblWorkshopsTitle: 'Workshop Title', | ||
lblSupportTitle: 'Support Title', | ||
lblCohortsTitle: 'Cohorts Title', | ||
lblWorkshopsContent: 'Workshop Content', | ||
lblSupportContent: 'Support Content', | ||
lblCohortsContent: 'Cohorts Content', | ||
btnTextMeetup: 'Join Meetup', | ||
btnTextCommunity: 'Join Community', | ||
btnTextCohort: 'Join Cohort', | ||
meetupUrl: 'https://meetup.com', | ||
communityUrl: 'https://community.com', | ||
cohortUrl: 'https://cohort.com', | ||
}; | ||
|
||
test('uses the correct href for each link', () => { | ||
render(<CardsSection label={labelMock} />); | ||
const meetupLink = screen.getByRole('link', { name: /join meetup/i }); | ||
const communityLink = screen.getByRole('link', { name: /join community/i }); | ||
const cohortLink = screen.getByRole('link', { name: /join cohort/i }); | ||
expect(meetupLink).toHaveAttribute('href', labelMock.meetupUrl); | ||
expect(communityLink).toHaveAttribute('href', labelMock.communityUrl); | ||
expect(cohortLink).toHaveAttribute('href', labelMock.cohortUrl); | ||
}); | ||
|
||
test('passes the correct content to each card', () => { | ||
render(<CardsSection label={labelMock} />); | ||
expect(screen.getByText(labelMock.lblWorkshopsTitle)).toBeInTheDocument(); | ||
expect(screen.getByText(labelMock.lblWorkshopsContent)).toBeInTheDocument(); | ||
expect(screen.getByText(labelMock.btnTextMeetup)).toBeInTheDocument(); | ||
expect(screen.getByText(labelMock.lblSupportTitle)).toBeInTheDocument(); | ||
expect(screen.getByText(labelMock.lblSupportContent)).toBeInTheDocument(); | ||
expect(screen.getByText(labelMock.btnTextCommunity)).toBeInTheDocument(); | ||
expect(screen.getByText(labelMock.lblCohortsTitle)).toBeInTheDocument(); | ||
expect(screen.getByText(labelMock.lblCohortsContent)).toBeInTheDocument(); | ||
expect(screen.getByText(labelMock.btnTextCohort)).toBeInTheDocument(); | ||
}); | ||
}); |