Skip to content
This repository was archived by the owner on Mar 1, 2025. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions src/test/unit/components/social-media-icon/index.test.js
Original file line number Diff line number Diff line change
@@ -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(<SocialMediaIcon id={testData.id} type={testData.type} />)
);

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]}`
);
});
});