Skip to content

Commit

Permalink
Format and clean up code
Browse files Browse the repository at this point in the history
  • Loading branch information
xsarahyu committed Apr 15, 2024
1 parent 0b820f3 commit 4f6ce95
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 69 deletions.
2 changes: 0 additions & 2 deletions app/src/components/Footer.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import React from 'react'

const Footer = () => {
return (
<footer className="bg-gray-800 py-4">
Expand Down
10 changes: 5 additions & 5 deletions app/src/components/Footer.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ import '@testing-library/jest-dom'
import Footer from './Footer'

describe('Footer component', () => {
test('renders Footer content', () => {
render(<Footer />)
const footerContent = screen.getByText(/Resilient Coders/)
expect(footerContent).toBeInTheDocument()
})
test('Renders Footer content', () => {
render(<Footer />)
const footerContent = screen.getByText(/Resilient Coders/)
expect(footerContent).toBeInTheDocument()
})
})
11 changes: 5 additions & 6 deletions app/src/components/LandingPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import { render, screen } from '@testing-library/react'
import '@testing-library/jest-dom'
import LandingPage from './LandingPage'


describe('LandingPage component', () => {
test('renders LandingPage content', () => {
render(<LandingPage />)
const welcomeContent = screen.getByText(/Welcome to the Resilient Coders AI ChatBot!/i)
expect(welcomeContent).toBeInTheDocument()
})
test('Renders LandingPage content', () => {
render(<LandingPage />)
const welcomeContent = screen.getByText(/Welcome to the Resilient Coders AI ChatBot!/i)
expect(welcomeContent).toBeInTheDocument()
})
})
2 changes: 1 addition & 1 deletion app/src/components/LoginPage.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -61,4 +61,4 @@ const LoginPage = () => {
)
}

export default LoginPage
export default LoginPage
20 changes: 10 additions & 10 deletions app/src/components/LoginPage.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,18 @@ import '@testing-library/jest-dom'
import LoginPage from './LoginPage.jsx'

describe('Login page component', () => {
test('renders login page ', () => {
const { getByTestId } = render(
<BrowserRouter>
<LoginPage />
</BrowserRouter>
);
test('Renders Login page ', () => {
const { getByTestId } = render(
<BrowserRouter>
<LoginPage />
</BrowserRouter>
)

const username = getByTestId('username');
expect(username).toBeInTheDocument();
const username = getByTestId('username')
expect(username).toBeInTheDocument()

})
})
})

// click of button redirects you to messages
// that the landing page renders , test for content on DOM
// that the landing page renders, test for content on DOM
2 changes: 1 addition & 1 deletion app/src/components/MessagesComponent.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -110,4 +110,4 @@ const MessagesComponent = () => {
)
}

export default MessagesComponent
export default MessagesComponent
42 changes: 20 additions & 22 deletions app/src/components/MessagesComponent.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,30 @@ import MessagesComponent from './MessagesComponent'


describe('Messages component', () => {
test('renders Message content', () => {
const { getByTestId, getByText } = render(<MessagesComponent />)
test('Renders Message content', () => {
const { getByTestId, getByText } = render(<MessagesComponent />)

const inputField = getByTestId('messageInput');
const inputField = getByTestId('messageInput')
fireEvent.change(inputField, { target: { value: 'hello' } })

fireEvent.change(inputField, { target: { value: 'hello' } });
const sendButton = getByTestId('submitMessageButton')
fireEvent.click(sendButton)

const sendButton = getByTestId('submitMessageButton');
fireEvent.click(sendButton);
const messageContent = getByText("hello")
expect(messageContent).toBeInTheDocument()
}),

const messageContent = getByText("hello")
expect(messageContent).toBeInTheDocument()
}),
test('if input placeholder exist', () => {
const {getByPlaceholderText } = render(<MessagesComponent />)
test('Message input exists', () => {
const { getByPlaceholderText } = render(<MessagesComponent />)

const inputPlaceholder = getByPlaceholderText('Type your message here...')
const inputPlaceholder = getByPlaceholderText('Type your message here...')
expect(inputPlaceholder).toBeInTheDocument()
}),

expect(inputPlaceholder).toBeInTheDocument()
}),
test('if send button exist', () => {
const { getByTestId} = render(<MessagesComponent />)

const submitBtn = getByTestId('submitMessageButton')

expect(submitBtn).toBeInTheDocument()
})
})
test('Button to send message exists', () => {
const { getByTestId } = render(<MessagesComponent />)

const submitBtn = getByTestId('submitMessageButton')
expect(submitBtn).toBeInTheDocument()
})
})
2 changes: 1 addition & 1 deletion app/src/components/NavBar.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const NavBar = () => {
return (
<nav className="bg-rc-red py-2 flex items-center px-44">
<div>
<img src={Skull} alt="skullImage" className="w-14"/>
<img src={Skull} alt="skullImage" className="w-14" />
</div>
<ul className="flex justify-center flex-1">
<li className="mx-6">
Expand Down
31 changes: 10 additions & 21 deletions app/src/components/NavBar.test.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,15 @@ import '@testing-library/jest-dom'
import { BrowserRouter } from 'react-router-dom'
import NavBar from './NavBar'

describe('Nav bar component', () => {
test('renders Nav Bar ', () => {
const { getByTestId } = render(
<BrowserRouter>
<NavBar />
</BrowserRouter>
);
describe('NavBar component', () => {
test('Renders NavBar', () => {
const { getByTestId } = render(
<BrowserRouter>
<NavBar />
</BrowserRouter>
)

const homeLink = getByTestId('homeNavBarButton');
expect(homeLink).toBeInTheDocument();

}),
test('renders Nav Bar ', () => {
const { getByTestId } = render(
<BrowserRouter>
<NavBar />
</BrowserRouter>
);

const loginLink = getByTestId('loginNavBarButton');
expect(loginLink).toBeInTheDocument();
})
const homeLink = getByTestId('homeNavBarButton')
expect(homeLink).toBeInTheDocument()
})
})

0 comments on commit 4f6ce95

Please sign in to comment.