From 8c8014294820f5cc9c8e817fe57a7d04ab370f48 Mon Sep 17 00:00:00 2001 From: Jagoda11 Date: Mon, 23 Dec 2024 00:19:25 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=93=9D=20refactor=20CommitList=20componen?= =?UTF-8?q?t=20and=20tests;=20update=20ESLint=20rules=20to=20allow=20conso?= =?UTF-8?q?le=20logs=20and=20'any'=20type?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- eslint.config.js | 4 ++-- src/App.tsx | 9 ++------- src/components/CommitList.test.tsx | 28 +++------------------------- 3 files changed, 7 insertions(+), 34 deletions(-) diff --git a/eslint.config.js b/eslint.config.js index d149465..56a371f 100644 --- a/eslint.config.js +++ b/eslint.config.js @@ -33,8 +33,8 @@ export default [ ], '@typescript-eslint/explicit-module-boundary-types': 'warn', // Ensure functions have explicit return types '@typescript-eslint/no-unused-vars': 'warn', // Warn about unused variables - '@typescript-eslint/no-explicit-any': 'warn', // Warn about usage of the any type - 'no-console': 'warn', + '@typescript-eslint/no-explicit-any': 'off', // Warn about usage of the any type + 'no-console': 'off', 'jest/no-disabled-tests': 'warn', // Warn about disabled tests 'jest/no-focused-tests': 'error', // Error on focused tests 'jest/no-identical-title': 'error', diff --git a/src/App.tsx b/src/App.tsx index 3132a42..bc4f3f6 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -1,13 +1,11 @@ -import React, { useState, useEffect } from 'react' +import React from 'react' import { HashRouter as Router, Route, Routes, Link } from 'react-router-dom' import Auth from './components/Auth' import Dashboard from './components/Dashboard' import CommitList from './components/CommitList' -import { fetchUserRepos } from './api/githubApi' const App: React.FC = () => { const token = localStorage.getItem('githubToken') - const username = localStorage.getItem('githubUsername') ?? '' const isLocal = window.location.origin.includes('localhost') const basename = isLocal ? '/' : '/github-insights-dashboard' @@ -27,10 +25,7 @@ const App: React.FC = () => { ) : ( <> } /> - } - /> + } /> )} diff --git a/src/components/CommitList.test.tsx b/src/components/CommitList.test.tsx index d4c2399..238cc77 100644 --- a/src/components/CommitList.test.tsx +++ b/src/components/CommitList.test.tsx @@ -1,5 +1,5 @@ import React from 'react' -import { render, screen, fireEvent } from '@testing-library/react' +import { render, screen } from '@testing-library/react' import '@testing-library/jest-dom' import CommitList from './CommitList' @@ -17,30 +17,8 @@ describe('CommitList Component 🎉', () => { expect(screen.getByPlaceholderText('Search commits')).toBeInTheDocument() }) - it('🖊️ updates the username input value', () => { + it('🔍 renders without crashing', () => { render() - const usernameInput = screen.getByPlaceholderText('Enter GitHub username') - fireEvent.change(usernameInput, { target: { value: 'testuser' } }) - expect(usernameInput).toHaveValue('testuser') - }) - - it('🔍 updates the search input value', () => { - render() - 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() - 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() + expect(screen.getByText('Commit List')).toBeInTheDocument() }) })