Skip to content

Commit

Permalink
Em tests (#740)
Browse files Browse the repository at this point in the history
  • Loading branch information
GoldGroove06 authored Jan 4, 2025
1 parent aa70714 commit bfc234b
Showing 1 changed file with 35 additions and 0 deletions.
35 changes: 35 additions & 0 deletions src/components/ui/Em/tests/Em.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import Em from '../Em';

describe('Em', () => {
test('renders Em component', () => {
render(<>Welcome to <Em>RadUI</Em></>);
expect(screen.getByText('RadUI')).toBeInTheDocument();
});

test('renders Em tag with valid text', () => {
render(<>Welcome to <Em>RadUI</Em></>);
expect(screen.getByText('RadUI').tagName.toLowerCase()).toBe('em');
});

test('renders custom classes correctly', () => {
render(<>Welcome to <Em className="custom-class">RadUI</Em></>);
expect(screen.getByText('RadUI')).toHaveClass('custom-class');
});

test('renders custom styles correctly', () => {
render(<>Welcome to <Em style={{ color: 'red' }}>RadUI</Em></>);
expect(screen.getByText('RadUI')).toHaveStyle('color: red');
});

test('renders custom id correctly', () => {
render(<>Welcome to <Em id="em-id">RadUI</Em></>);
expect(screen.getByText('RadUI')).toHaveAttribute('id', 'em-id');
});

test('renders custom data attribute correctly', () => {
render(<>Welcome to <Em data-testid="em-data">RadUI</Em></>);
expect(screen.getByText('RadUI')).toHaveAttribute('data-testid', 'em-data');
});
});

0 comments on commit bfc234b

Please sign in to comment.