diff --git a/src/test/unit/components/social-media-icon/index.test.js b/src/test/unit/components/social-media-icon/index.test.js new file mode 100644 index 00000000..3a803a6d --- /dev/null +++ b/src/test/unit/components/social-media-icon/index.test.js @@ -0,0 +1,35 @@ +import { render, screen } from '@testing-library/react'; +import SocialMediaIcon from '@components/social-media-icon'; +import iconMapper from '@components/social-media-icon/social-media.constant'; + +const testData = { + id: 'ankushdharkar', + type: 'linkedin_id', +}; + +describe('describe Social Media Icon', () => { + beforeEach(() => + render() + ); + + it('Should render img icon properly ', () => { + const socialMediaIcon = screen.getByAltText('linkedIn'); + expect(socialMediaIcon).toBeInTheDocument(); + expect(socialMediaIcon).toHaveAttribute( + 'src', + iconMapper[testData.type].src + ); + }); + + it('Should render the info icon correctly', () => { + const socialMediaAnchor = document.querySelector('a'); + + expect(socialMediaAnchor).toHaveAttribute('target', '_blank'); + expect(socialMediaAnchor).toHaveAttribute('rel', 'noreferrer'); + expect(socialMediaAnchor).toHaveAttribute('tabIndex', '0'); + expect(socialMediaAnchor).toHaveAttribute( + 'href', + `${iconMapper[testData.type].href}/${[testData.id]}` + ); + }); +});