Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Functionality test #2

Merged
merged 44 commits into from
Jul 1, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
cee8a54
Modify the App.js to add routes.
ab-noori Jun 29, 2023
9c1201b
Modify the index.js to add router and store provider.
ab-noori Jun 29, 2023
4a35b44
Add redux store.
ab-noori Jun 29, 2023
6e991ed
Add currencySlicer to fetch trends and serched currencies.
ab-noori Jun 29, 2023
65f1662
Display the Trends and searched currencies in Homepage.
ab-noori Jun 29, 2023
e881e2f
Add Show pages to display the details of each currencies.
ab-noori Jun 29, 2023
77ca319
Add some configruration and installations.
ab-noori Jun 29, 2023
2bb71e4
Add details slicer to fetch detailed data and define some actions.
ab-noori Jun 29, 2023
c55a05b
Modify store to add detail reducer.
ab-noori Jun 29, 2023
3b97bf2
Install Millify to foramt the numbers.
ab-noori Jun 29, 2023
93e9d22
Update the app.jsx to add routes and clean the codebase.
ab-noori Jun 30, 2023
e9594b1
Update the slicer to fetch detailed data.
ab-noori Jun 30, 2023
05ca476
Update the slicer to fetch all currency data.
ab-noori Jun 30, 2023
bdaa68c
Update the Home page component to display the general currencies.
ab-noori Jun 30, 2023
b23d797
Update the Show page component to show the each currency details.
ab-noori Jun 30, 2023
5fd7a65
Add the installation and configurations.
ab-noori Jun 30, 2023
1fa8ea8
Add the Navbar to show the page titles.
ab-noori Jun 30, 2023
feabf27
Add the Navbar styles.
ab-noori Jun 30, 2023
1d1faf3
Add the DetailsView component.
ab-noori Jun 30, 2023
cca0ed3
Add styles for details components
ab-noori Jun 30, 2023
da1e1a6
Add the CurrencyList component to list all data
ab-noori Jun 30, 2023
a41357e
Add Styles for currency list.
ab-noori Jun 30, 2023
e554f2c
Add the Footer component.
ab-noori Jul 1, 2023
e4a1418
Add the style to Footer component.
ab-noori Jul 1, 2023
b48283f
Add the SearchBar Footer component for searching currencies..
ab-noori Jul 1, 2023
e610e40
Add the style to SearchBar component.
ab-noori Jul 1, 2023
a7f6a48
Add test for footer..
ab-noori Jul 1, 2023
85fb85b
Add test for Navbar.
ab-noori Jul 1, 2023
8c2eb2d
Add test for SearchBar.
ab-noori Jul 1, 2023
860866e
Add test for DetailsView.
ab-noori Jul 1, 2023
97fb5d8
Add test for CurrencyList.
ab-noori Jul 1, 2023
ead1ae9
Add the Project images.
ab-noori Jul 1, 2023
53c6a15
Add the snapshot tests.
ab-noori Jul 1, 2023
ad03c4d
Upadate the readme file to add the project images and acknowledgments.
ab-noori Jul 1, 2023
a5f4124
Modify the app.jsx to include footer components
ab-noori Jul 1, 2023
27d436d
Set the font famaily for the whole project.
ab-noori Jul 1, 2023
8fabc72
Add test for search component
ab-noori Jul 1, 2023
3cf855f
Modify the currencyList to separate the search component
ab-noori Jul 1, 2023
c757022
Modify the currency slice
ab-noori Jul 1, 2023
c0301d1
Give style to currency list and currency details.
ab-noori Jul 1, 2023
8d9050b
Modify the navbar conditions.
ab-noori Jul 1, 2023
2483b21
Modify the style for navabar
ab-noori Jul 1, 2023
6254dc2
Remove the liter errors.
ab-noori Jul 1, 2023
1923496
Remove Linter error.
ab-noori Jul 1, 2023
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
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,4 @@
npm-debug.log*
yarn-debug.log*
yarn-error.log*

17 changes: 9 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@

| Desktop View Representation|
|---------------------------------------|
|<div align="center"><img src="./src/assets/project-image.jpg" alt="screenshot" width="auto" height="auto"/></div>|
|<div align="center"><img src="./src/assets/project-image.jpg" alt="screenshot" width="auto" height="auto"/></div>|
|<div align="center"><img src="./src/assets/project-image1.PNG" alt="screenshot" width="auto" height="auto"/></div>|
|<div align="center"><img src="./src/assets/project-image2.PNG" alt="screenshot" width="auto" height="auto"/></div>|
|<div align="center"><img src="./src/assets/mobile-shot1.PNG" alt="screenshot" width="auto" height="400"/>
<img src="./src/assets/mobile-shot2.PNG" alt="screenshot" width="auto" height="400"/></div>|

<!-- TABLE OF CONTENTS -->

Expand Down Expand Up @@ -115,8 +117,7 @@ Clone this repository to your desired folder:
### Install
- Install this project with:

npx create-react-app my-app
cd my-app
npx create-react-app .
npm start


Expand Down Expand Up @@ -168,8 +169,9 @@ Clone this repository to your desired folder:

## 🔭 Future Features <a name="future-features"></a>

- [ ] **[Add About page]**
- [ ] **[Add Contact page]**
- [ ] **[Giving funtionality to search input]**
- [ ] **[Using Charts and graph to disply the currencies data]**
- [ ] **[Using Creating Professional sidebar panel]**

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand All @@ -191,8 +193,7 @@ Feel free to check the [issues page](https://github.com/ab-noori/Cryptopanel/iss

## 🙏 Acknowledgments <a name="acknowledgements"></a>

I would like to thank Microverse and my coding partners. Also, I want to give credit to [`Nerd's lesson`](https://www.youtube.com/@Nerdslesson)
YouTub Channel, its [`react tutorial`](https://www.youtube.com/watch?v=cd3P3yXyx30) is really helpful.
First, I would like to thank Microverse and my coding partners. Second, I want to give credit to [`Nerd's lesson`](https://www.youtube.com/@Nerdslesson) YouTub Channel, its [`react tutorial`](https://www.youtube.com/watch?v=cd3P3yXyx30) is really helpful, and third, I should give credit to Nelson Sakwa, I got some inspirations from his design on Behance.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

Expand Down
87 changes: 87 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,15 @@
"@testing-library/jest-dom": "^5.16.5",
"@testing-library/react": "^13.4.0",
"@testing-library/user-event": "^13.5.0",
"axios": "^1.4.0",
"classnames": "^2.3.2",
"gh-pages": "^5.0.0",
"millify": "^6.1.0",
"prop-types": "^15.8.1",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"react-redux": "^8.1.1",
"react-router": "^6.14.0",
"react-router-dom": "^6.14.0",
"react-scripts": "5.0.1",
"redux": "^4.2.1",
Expand Down
16 changes: 15 additions & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,25 @@
import { Routes, Route } from 'react-router';
import './App.scss';
import Show from './pages/Show';
import Home from './pages/Home';
import Navbar from './components/Navbar';
import Footer from './components/Footer';

function App() {
return (
<div className="App">
<header className="App-header">
<h1>Crypto Panel</h1>
<Navbar />
</header>
<main>
<Routes>
<Route path="/Cryptopanel/" element={<Home />} />
<Route path="/Cryptopanel/:id" element={<Show />} />
</Routes>
</main>
<footer>
<Footer />
</footer>
</div>
);
}
Expand Down
4 changes: 3 additions & 1 deletion src/App.scss
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@import url('https://fonts.googleapis.com/css2?family=Lato:ital,wght@0,300;0,400;0,700;0,900;1,100;1,300;1,400;1,700;1,900&family=Satisfy&display=swap');

.App {
text-align: center;
font-family: 'Lato', sans-serif;
}
36 changes: 36 additions & 0 deletions src/__tests__/CurrencyList.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
import React from 'react';
import { render } from '@testing-library/react';
import { BrowserRouter as Router } from 'react-router-dom';
import CurrencyList from '../components/CurrencyList';

test('renders CurrencyList component correctly', () => {
const currencies = [
{
id: 1,
rank: 1,
name: 'Bitcoin',
image: 'bitcoin.png',
symbol: 'BTC',
currentPrice: 50000,
oneHourPriceChange: 0.5,
oneDayPriceChange: 1.2,
oneWeekPriceChange: -0.8,
totalVolume: 1000000,
marketCap: 1000000000,
},
// Add more sample data as needed
];

const { container } = render(
<Router>
<CurrencyList
currencies={currencies}
query=""
handleQuery={() => {}}
handleKeyDown={() => {}}
/>
</Router>,
);

expect(container).toMatchSnapshot();
});
32 changes: 32 additions & 0 deletions src/__tests__/DetailsView.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { render } from '@testing-library/react';
import DetailsView from '../components/DetailsView';

test('renders DetailsView correctly', () => {
const props = {
marketCapRank: 1,
currentPrice: 1000,
marketCap: 1000000,
marketCapChange24h: 5000,
high24h: 1500,
low24h: 800,
priceChange24h: 200,
priceChangePercentage24h: 0.2,
marketCapChangePercentage24: 0.5,
ath: 2000,
athChangePercentage: 0.4,
atl: 500,
atlChangePercentage: 0.1,
fullyDilutedValuation: 2000000,
totalVolume: 50000,
totalSupply: 1000000,
circulatingSupply: 800000,
maxSupply: 2000000,
publicInterestScore: 0.8,
};

/* eslint-disable react/jsx-props-no-spreading */
const { container } = render(<DetailsView {...props} />);

expect(container).toMatchSnapshot();
});
10 changes: 10 additions & 0 deletions src/__tests__/Footer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { render } from '@testing-library/react';
import Footer from '../components/Footer';

describe('Footer component', () => {
test('renders correctly', () => {
const { asFragment } = render(<Footer />);
expect(asFragment()).toMatchSnapshot();
});
});
49 changes: 49 additions & 0 deletions src/__tests__/Navbar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import React from 'react';
import { render } from '@testing-library/react';
import { BrowserRouter as Router } from 'react-router-dom';
import { useSelector } from 'react-redux';
import Navbar from '../components/Navbar';

jest.mock('react-redux', () => ({
useSelector: jest.fn(),
}));

describe('Navbar component', () => {
beforeEach(() => {
useSelector.mockClear();
});

test('renders correctly when on Cryptopanel page', () => {
useSelector.mockReturnValue({
CurrencyDetails: {
name: 'Bitcoin',
symbol: 'BTC',
},
});

const { container } = render(
<Router>
<Navbar />
</Router>,
);

expect(container.firstChild).toMatchSnapshot();
});

test('renders correctly when not on Cryptopanel page', () => {
useSelector.mockReturnValue({
CurrencyDetails: {
name: 'Ethereum',
symbol: 'ETH',
},
});

const { container } = render(
<Router>
<Navbar />
</Router>,
);

expect(container.firstChild).toMatchSnapshot();
});
});
15 changes: 15 additions & 0 deletions src/__tests__/SearchBar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from 'react';
import { render } from '@testing-library/react';
import SearchBar from '../components/SearchBar';

test('SearchBar component matches snapshot', () => {
const { container } = render(
<SearchBar
value="test value"
onChange={() => {}}
onKeyDown={() => {}}
/>,
);

expect(container.firstChild).toMatchSnapshot();
});
Loading