-
-
Notifications
You must be signed in to change notification settings - Fork 773
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adding unit tests for support-us,Testimonial and JobSummary com…
…ponent (#1813) Co-authored-by: akshatnema <20bcs022@iiitdmj.ac.in>
- Loading branch information
1 parent
bd1c6bf
commit 53e7517
Showing
9 changed files
with
224 additions
and
109 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 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
export const items = [ | ||
{ | ||
href: "https://slack.com/media-kit", | ||
imgSrc: "/img/supportus/slack.webp", | ||
imgTitle: "Slack - Free Standard Subscription.", | ||
imgClass: "inline-block px-4 sm:h-10", | ||
section: 1, | ||
}, | ||
{ | ||
href: "https://toast.ninja/", | ||
imgSrc: "/img/supportus/toast.webp", | ||
imgTitle: "Toast - Free services.", | ||
imgClass: "inline-block px-4 sm:h-10", | ||
section: 1, | ||
}, | ||
{ | ||
href: "https://www.netlify.com/", | ||
imgSrc: "/img/supportus/netlify.webp", | ||
imgTitle: "Netlify - Free website deployment.", | ||
imgClass: "inline-block px-4 sm:h-10", | ||
section: 1, | ||
}, | ||
{ | ||
href: "https://sonarcloud.io/", | ||
imgSrc: "/img/supportus/sonarcloud.webp", | ||
imgTitle: "Sonarcloud - Free tier for automated project scanning.", | ||
imgClass: "inline-block px-4 md:h-14", | ||
section: 2, | ||
}, | ||
{ | ||
href: "https://www.digitalocean.com/press/", | ||
imgSrc: "/img/supportus/digitalocean.webp", | ||
imgTitle: "DigitalOcean - 500 dollars on cloud services.", | ||
imgClass: "inline-block px-2 sm:h-8", | ||
section: 2, | ||
}, | ||
{ | ||
href: "https://restream.io/", | ||
imgSrc: "/img/supportus/restream.webp", | ||
imgTitle: "Restream - Free professional plan subscription.", | ||
imgClass: "inline-block px-4 sm:h-6", | ||
section: 2, | ||
}, | ||
{ | ||
href: "https://sessionize.com/", | ||
imgSrc: "/img/supportus/sessionize.webp", | ||
imgTitle: "Sessionize-Free community license for AACoT Madrid.", | ||
imgClass: "inline-block px-4 sm:h-9", | ||
section: 3, | ||
}, | ||
]; |
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,65 @@ | ||
import { items } from "./SupportItemsList"; | ||
export default function SupportUs({ className = '', showSupportBanner = true }) { | ||
return ( | ||
<div className={ `text-center ${ className }` } data-testid="SupportUs-main"> | ||
<div className="flex flex-wrap md:mb-4 sm:py-2 items-center justify-center md:px-4" data-testid="SupportUs-section"> | ||
{ items | ||
.filter((item) => item.section === 1) | ||
.map((item, index) => ( | ||
<a | ||
key={ index } | ||
href={ item.href } | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className='block relative text-center w-2/3 px-4 py-4 sm:p-0 sm:w-1/3 md:w-1/3 lg:w-1/5' | ||
> | ||
<img | ||
className={ item.imgClass } | ||
src={ item.imgSrc } | ||
title={ item.imgTitle } | ||
/> | ||
</a> | ||
)) } | ||
</div> | ||
<div className="flex flex-wrap mb-4 items-center justify-center md:px-2" data-testid="SupportUs-subsection"> | ||
{ items | ||
.filter((item) => item.section === 2) | ||
.map((item, index) => ( | ||
<a | ||
key={ index } | ||
href={ item.href } | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className='block relative text-center w-2/3 px-4 py-4 sm:p-0 sm:w-1/3 md:w-1/3 lg:w-1/5' | ||
> | ||
<img | ||
className={ item.imgClass } | ||
src={ item.imgSrc } | ||
title={ item.imgTitle } | ||
/> | ||
</a> | ||
)) } | ||
</div> | ||
<div className="flex flex-wrap mb-4 items-center justify-center md:px-2" data-testid="SupportUs-last-div"> | ||
{ items | ||
.filter((item) => item.section === 3) | ||
.map((item, index) => ( | ||
<a | ||
key={ index } | ||
href={ item.href } | ||
target="_blank" | ||
rel="noopener noreferrer" | ||
className='block relative text-center w-2/3 px-4 py-4 sm:p-0 sm:w-1/3 md:w-1/3 lg:w-1/5' | ||
> | ||
<img | ||
className={ item.imgClass } | ||
src={ item.imgSrc } | ||
title={ item.imgTitle } | ||
/> | ||
</a> | ||
)) } | ||
</div> | ||
</div> | ||
); | ||
} | ||
|
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,18 @@ | ||
import { mount } from 'cypress/react'; | ||
import JobSummary from '../../components/JobSummary'; | ||
describe('JobSummary', () => { | ||
it('renders job summary with correct information', () => { | ||
const job = { | ||
location: 'remote', | ||
region: 'Anywhere (on planet Earth)', | ||
employmentType: 'Full-time', | ||
closingOn: 'Closing on June 30, 2023', | ||
}; | ||
|
||
mount(<JobSummary job={job} className="custom-class" />); | ||
cy.get('[data-testid="JobSummary-dd"]').contains('Remote').should('exist'); | ||
cy.get('[data-testid="JobSummary-paragraph"]').contains('Anywhere (on planet Earth)').should('exist'); | ||
cy.contains(job.employmentType).should('exist'); | ||
cy.contains(job.closingOn).should('exist'); | ||
}); | ||
}); |
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,53 @@ | ||
import SupportUs from '../../components/SupportUs/SupportUs'; | ||
describe('SupportUs component', () => { | ||
beforeEach(() => { | ||
cy.mount(<SupportUs />); | ||
}); | ||
|
||
it('renders the SupportUs component', () => { | ||
cy.get('[data-testid="SupportUs-main"]') | ||
.should('be.visible') | ||
.within(() => { | ||
cy.get('[data-testid="SupportUs-section"]').should('exist'); // First section div | ||
cy.get('[data-testid="SupportUs-subsection"]').should('exist'); // Second section div | ||
cy.get('[data-testid="SupportUs-last-div"]').should('exist'); // Third section div | ||
}); | ||
}); | ||
|
||
it('renders correct number of items in each section', () => { | ||
cy.get('[data-testid="SupportUs-section"]').find('a').should('have.length', 3); // First section | ||
cy.get('[data-testid="SupportUs-subsection"]').find('a').should('have.length', 3); // Second section | ||
cy.get('[data-testid="SupportUs-last-div"]').find('a').should('have.length', 1); // Third section | ||
}); | ||
|
||
it('opens links in new tab', () => { | ||
cy.get('[data-testid="SupportUs-main"]').each((section) => { | ||
cy.wrap(section) | ||
.find('a') | ||
.each((link) => { | ||
cy.wrap(link).should('have.attr', 'target', '_blank'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('has valid href attribute in each link', () => { | ||
cy.get('[data-testid="SupportUs-main"]').each((section) => { | ||
cy.wrap(section) | ||
.find('a') | ||
.each((link) => { | ||
cy.wrap(link).should('have.attr', 'href').and('not.be.empty'); | ||
}); | ||
}); | ||
}); | ||
|
||
it('displays the correct image in each item', () => { | ||
cy.get('[data-testid="SupportUs-main"]').each((section) => { | ||
cy.wrap(section) | ||
.find('a') | ||
.each((link) => { | ||
cy.wrap(link).find('img').should('have.attr', 'src').and('not.be.empty'); | ||
}); | ||
}); | ||
}); | ||
|
||
}); |
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,27 @@ | ||
import { mount } from 'cypress/react'; | ||
import Testimonial from '../../components/Testimonial'; | ||
|
||
describe('Testimonial Component', () => { | ||
it('should render the testimonial with correct data', () => { | ||
const testimonialData = { | ||
text: 'This is a test testimonial.', | ||
authorName: 'Lukasz Gornicki', | ||
authorDescription: 'CEO at Company', | ||
authorAvatar: '/img/avatars/lpgornicki.webp', | ||
}; | ||
mount( | ||
<Testimonial | ||
text={ testimonialData.text } | ||
authorName={ testimonialData.authorName } | ||
authorDescription={ testimonialData.authorDescription } | ||
authorAvatar={ testimonialData.authorAvatar } | ||
/> | ||
); | ||
|
||
cy.contains(testimonialData.text); | ||
cy.contains(testimonialData.authorName); | ||
cy.contains(testimonialData.authorDescription); | ||
cy.get('[data-testid="Testimonial-img"]').should('have.attr', 'src', testimonialData.authorAvatar); | ||
cy.get('[data-testid="Testimonial-img"]').should('have.attr', 'alt', testimonialData.authorName); | ||
}); | ||
}); |
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