generated from Jagoda11/react-template
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
📝 enhance CommitList tests for input handling and error display; refa…
…ctor Summary layout for improved styling
- Loading branch information
Showing
2 changed files
with
42 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,46 @@ | ||
import React from 'react' | ||
import { render, screen, fireEvent } from '@testing-library/react' | ||
import '@testing-library/jest-dom' | ||
import CommitList from './CommitList' | ||
|
||
describe('CommitList', () => { | ||
it('✅ should be defined', () => { | ||
describe('CommitList Component 🎉', () => { | ||
it('✅ should be defined ✨', () => { | ||
expect(CommitList).toBeDefined() | ||
}) | ||
|
||
it('🎨 renders the component correctly', () => { | ||
render(<CommitList />) | ||
expect(screen.getByText('Commit List')).toBeInTheDocument() | ||
expect( | ||
screen.getByPlaceholderText('Enter GitHub username'), | ||
).toBeInTheDocument() | ||
expect(screen.getByPlaceholderText('Search commits')).toBeInTheDocument() | ||
}) | ||
|
||
it('🖊️ updates the username input value', () => { | ||
render(<CommitList />) | ||
const usernameInput = screen.getByPlaceholderText('Enter GitHub username') | ||
fireEvent.change(usernameInput, { target: { value: 'testuser' } }) | ||
expect(usernameInput).toHaveValue('testuser') | ||
}) | ||
|
||
it('🔍 updates the search input value', () => { | ||
render(<CommitList />) | ||
const searchInput = screen.getByPlaceholderText('Search commits') | ||
fireEvent.change(searchInput, { target: { value: 'fix' } }) | ||
expect(searchInput).toHaveValue('fix') | ||
}) | ||
|
||
it('⚠️ displays an error message if no username is entered', () => { | ||
render(<CommitList />) | ||
const usernameInput = screen.getByPlaceholderText('Enter GitHub username') | ||
const searchInput = screen.getByPlaceholderText('Search commits') | ||
|
||
fireEvent.change(usernameInput, { target: { value: '' } }) | ||
fireEvent.change(searchInput, { target: { value: 'anything' } }) | ||
|
||
expect( | ||
screen.queryByText('Error: Invalid username'), | ||
).not.toBeInTheDocument() | ||
}) | ||
}) |
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