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

Jun 1 #115

Open
wants to merge 40 commits into
base: master
Choose a base branch
from
Open

Jun 1 #115

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
40 commits
Select commit Hold shift + click to select a range
d76fd80
first commit
jgarciacentraal Jul 26, 2021
d5e996e
Merge pull request #1 from jgarciacentraal/mini-challenge-1
jgarciacentraal Jul 26, 2021
07792c9
intro testing
jgarciacentraal Jul 27, 2021
f088b95
Merge pull request #2 from jgarciacentraal/mini-challenge-2
jgarciacentraal Jul 27, 2021
1f69580
Search and display videos from API youtube
jgarciacentraal Aug 2, 2021
392cfad
Some components for videoDetail
jgarciacentraal Aug 3, 2021
f2fa2d7
Merge pull request #3 from jgarciacentraal/mini-challenge-3
jgarciacentraal Aug 3, 2021
68a3fab
remove .env from gitignore
jgarciacentraal Aug 3, 2021
feecedd
Merge pull request #4 from jgarciacentraal/mini-challenge-3
jgarciacentraal Aug 3, 2021
7f92971
display video
jgarciacentraal Aug 4, 2021
42b1552
Merge pull request #5 from jgarciacentraal/mini-challenge-3
jgarciacentraal Aug 4, 2021
6b9c9b0
some styles
jgarciacentraal Aug 7, 2021
a6f15a3
some testing files
jgarciacentraal Aug 7, 2021
c5cc960
Merge pull request #6 from jgarciacentraal/mini-challenge-3
jgarciacentraal Aug 7, 2021
fd5935a
modifiy throw loading.. in Home view
jgarciacentraal Aug 7, 2021
0efd036
modifiy throw loading.. in Home view and coverage
jgarciacentraal Aug 7, 2021
49e3768
Another features
jgarciacentraal Aug 10, 2021
bac1783
Merge pull request #7 from jgarciacentraal/mini-challenge-3
jgarciacentraal Aug 10, 2021
5f7e78c
resolving issues
jgarciacentraal Aug 16, 2021
18803b0
resolved some issues
jgarciacentraal Aug 16, 2021
d01d58d
resolved some issues
jgarciacentraal Aug 16, 2021
dcbabc5
Merge pull request #8 from jgarciacentraal/mini-challenge-3
jgarciacentraal Aug 16, 2021
ee81752
Context
jgarciacentraal Aug 17, 2021
4347e8b
Merge pull request #9 from jgarciacentraal/miniChallenge4
jgarciacentraal Aug 17, 2021
50e9578
typos
jgarciacentraal Aug 17, 2021
d43708d
Issue with useEffect in VideoPage
jgarciacentraal Aug 17, 2021
abc94b7
Merge pull request #10 from jgarciacentraal/miniChallenge4
jgarciacentraal Aug 17, 2021
eace279
add sidebar
jgarciacentraal Aug 25, 2021
a7b268c
Merge pull request #11 from jgarciacentraal/miniChallenge4
jgarciacentraal Aug 25, 2021
794354a
·some issues
jgarciacentraal Aug 25, 2021
0be3b46
Add fn session data, favorites video page and some features more
jgarciacentraal Aug 29, 2021
2ed9938
Merge pull request #12 from jgarciacentraal/miniChallenge5
jgarciacentraal Aug 29, 2021
cf5a60f
fixed features and remove logs
jgarciacentraal Aug 29, 2021
cf01968
..
jgarciacentraal Aug 29, 2021
cf7a3d9
fix issue with aria
jgarciacentraal Aug 30, 2021
d753bc7
Merge pull request #13 from jgarciacentraal/miniChallenge5
jgarciacentraal Aug 30, 2021
50e8a4d
fixed issue en favorites
jgarciacentraal Aug 31, 2021
3efd5e9
Merge pull request #14 from jgarciacentraal/miniChallenge5
jgarciacentraal Aug 31, 2021
ecd1c53
Update coverage
jgarciacentraal Aug 31, 2021
56060d0
refactor home view, added another component for wrapping list videos
Jun 25, 2022
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 .env
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_API_KEY=AIzaSyCruBQW1jnCJftpdNWkTEQOecAzlaBqad0
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# See https://help.github.com/articles/ignoring-files/ for more about ignoring files.

# enviroment

# dependencies
/node_modules
/.pnp
Expand Down
6 changes: 6 additions & 0 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"compilerOptions": {
"baseUrl": "src"
},
"include": ["src"]
}
34,513 changes: 34,513 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

18 changes: 17 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,20 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@material-ui/core": "^4.12.3",
"@material-ui/icons": "^4.11.2",
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^10.4.9",
"@testing-library/react-hooks": "^7.0.1",
"@testing-library/user-event": "^12.1.3",
"history": "^4.10.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-feather": "^2.0.9",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3"
"react-scripts": "3.4.3",
"styled-components": "^5.3.0"
},
"scripts": {
"start": "react-scripts start",
Expand All @@ -34,6 +40,16 @@
"prettier": "^2.1.1",
"pretty-quick": "^3.0.0"
},
"jest": {
"coveragePathIgnorePatterns": [
"/node_modules/",
"/src/serviceWorker.js",
"/src/index.js"
],
"coverageReporters": [
"text"
]
},
"browserslist": {
"production": [
">0.2%",
Expand Down
5 changes: 5 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,16 @@
work correctly both with client-side routing and a non-root public URL.
Learn how to configure a non-root public URL by running `npm run build`.
-->
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>
<title>React App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
<div id="root"></div>
<div id="modal"></div>
<!--
This HTML file is a template.
If you open it directly in the browser, you will see an empty page.
Expand Down
18 changes: 18 additions & 0 deletions src/GlobalStyle.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { createGlobalStyle } from 'styled-components';

const GlobalStyle = createGlobalStyle`
body {
margin: 0;
padding: 0;
text-rendering: optimizeLegibility;
background: ${({ theme }) => theme.body};
color: ${({ theme }) => theme.text};
background-size: 400% 400%;
background-position: var(--bg-position);
transition: all 0.50s linear;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
}
`;

export default GlobalStyle;
19 changes: 19 additions & 0 deletions src/__test__/components/Header.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
// components
import Header from 'components/Header/Header';
import GlobalProvider from 'store/global.provider';

describe('Show header', () => {
it('render a header container', () => {
render(
<GlobalProvider value={{ theme: 'light' }}>
<Header />
</GlobalProvider>
);

const headerElement = screen.getByTestId('header-container');
expect(headerElement).toBeInTheDocument();
});

});
28 changes: 28 additions & 0 deletions src/__test__/components/ListRelativeVideos.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import * as React from 'react';
import {render, screen} from '@testing-library/react'
import List from 'components/ListRelativeVideos/List';

import { mockVideos } from '../../mockData';

const {items} = mockVideos;

const {videoId} = items[0].id


import GlobalProvider from 'store/global.provider';

describe('ListRelativeVideos Component ', () => {

test('render' , () => {
render(
<GlobalProvider>
< List videoId={videoId} />
</GlobalProvider>
)

const listCtn = screen.getByTestId('list-ctn')
expect(listCtn).toBeInTheDocument()

})

})
18 changes: 18 additions & 0 deletions src/__test__/components/LoginBtn.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import React from 'react';
import { render, screen } from '@testing-library/react';

import GlobalProvider from 'store/global.provider';
import LoginBtn from '../../components/LoginBtn/index';

describe('LoginBtn component', () => {
test('show Icon button', () => {
render(
<GlobalProvider>
<LoginBtn />
</GlobalProvider>
);

const iconEl = screen.getByTestId('btn-test');
expect(iconEl).toBeInTheDocument();
});
});
29 changes: 29 additions & 0 deletions src/__test__/components/Search.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import React from 'react';
import { render, screen } from '@testing-library/react';

import Search from 'components/Search/Search';
import GlobalProvider from 'store/global.provider';

describe('Search component', () => {
it('renders Input ', () => {
render(
<GlobalProvider>
<Search />
</GlobalProvider>
);

const inputEl = screen.getByTestId('search-input');
expect(inputEl).toBeInTheDocument();
});

it('renders Search container', () => {
render(
<GlobalProvider>
<Search />
</GlobalProvider>
);

const searchContainer = screen.getByTestId('search-container');
expect(searchContainer).toBeInTheDocument();
});
});
32 changes: 32 additions & 0 deletions src/__test__/components/SideBar.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Router } from 'react-router-dom';
import { createMemoryHistory } from 'history';

import SideBar from 'components/SideBar/SideBar';
import GlobalProvider from 'store/global.provider';

test('Test sidebar component', () => {
const history = createMemoryHistory();

const allProviders = ({ children }) => {
return (
<GlobalProvider>
<Router history={history}>{children}</Router>
</GlobalProvider>
);
};

const openSideBar = true;
const setOpenSideBar = jest.fn();

render(<SideBar open={openSideBar} toggleSideBar={setOpenSideBar} />, {
wrapper: allProviders,
});

const drawerElement = screen.getByTestId('sidebar-role');
expect(drawerElement).toBeInTheDocument();

const homeSection = screen.getByTestId('btn-home');
expect(homeSection).toBeInTheDocument();
});
19 changes: 19 additions & 0 deletions src/__test__/components/ThemeBtn.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import React from 'react';
import { render, screen } from '@testing-library/react';

import ThemeBtn from 'components/ThemeBtn';
import GlobalProvider from 'store/global.provider';

test('theme button', () => {
render(
<GlobalProvider>
<ThemeBtn />
</GlobalProvider>
);

const themeButton = screen.getByRole('button');
expect(themeButton).toBeInTheDocument();

const iconTheme = screen.getByTitle('MoonButton');
expect(iconTheme).toBeInTheDocument();
});
34 changes: 34 additions & 0 deletions src/__test__/components/VideoCard.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
import * as React from 'react';

import { render, screen } from '@testing-library/react';
import { Router } from 'react-router-dom';
import { createMemoryHistory } from 'history';

import VideoCard from 'components/VideoCard/VideoCard';
import GlobalProvider from 'store/global.provider';

import { mockFavorites } from '../../mockData';

const history = createMemoryHistory();
const allProviders = ({ children }) => {
return (
<GlobalProvider>
<Router history={history}>{children}</Router>
</GlobalProvider>
);
};

test('all video card in viewss', () => {
render(<VideoCard key={mockFavorites[0].videoId} data={mockFavorites[0]} />, {
wrapper: allProviders,
});

const cardE = screen.getByTestId('list-videos');
expect(cardE).toBeInTheDocument();

const titleE = screen.getByTestId('title-card-video');
expect(titleE).toBeInTheDocument();

const imagen = screen.getByRole('img');
expect(imagen).toBeInTheDocument();
});
52 changes: 52 additions & 0 deletions src/__test__/components/VideoDetail.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import React from 'react';
import { render, screen } from '@testing-library/react';
import { Router } from 'react-router-dom';
import { createMemoryHistory } from 'history';

import { mockFavorites } from '../../mockData'

import VideoDetail from 'components/VideoDetail/VideoDetail';
import GlobalProvider from 'store/global.provider';

const user = {
id: '123',
name: 'Wizeline',
avatarUrl:
'https://media.glassdoor.com/sqll/868055/wizeline-squarelogo-1473976610815.png',
};
const videoSelected = mockFavorites[1];
const favorite = true;


const history = createMemoryHistory();
const allProviders = ({ children }) => {
return (
<GlobalProvider>
<Router history={history}>{children}</Router>
</GlobalProvider>
);
};

test('Test PlayDetail component', async () => {
render(
<VideoDetail video={{ user, videoSelected, favorite }} />,
{ wrapper: allProviders }
);

// Looking for elements
const iFrame = screen.getByTitle('playVideo');
expect(iFrame).toBeInTheDocument();

const heading = screen.getByRole('heading', { level: 2 });
expect(heading).toBeInTheDocument();

const title = screen.getByTestId('title-detail');
expect(title).toBeInTheDocument();

const descrpition = screen.getByTestId('descrpition-detail');
expect(descrpition).toBeInTheDocument();

});



53 changes: 53 additions & 0 deletions src/__test__/hooks/useFetch.test.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
import { renderHook } from '@testing-library/react-hooks';

import { useFetch } from '../../utils/hooks/useFetch';

// import { mockVideos } from '../../mockData';

const promiseControl = () => {
let response;
const promise = new Promise((resolve, reject) => {
response = { resolve, reject };
});
return { response, promise };
};

describe('Testing useFetch hooks', () => {
it('Testing loading state', async () => {
const { response, promise } = promiseControl();
global.fetch = jest.fn(() => promise);

const { result, waitForNextUpdate } = renderHook(() => useFetch('CHzlSGRvWPs', true));

expect(result.current.loading).toBe(true);
response.resolve();

await waitForNextUpdate();
expect(result.current.loading).toBe(false);
});

// it('Getting data successfully', async () => {
// const { response, promise } = promiseControl();
// global.fetch = jest.fn(() => promise);

// const { result, waitForNextUpdate } = renderHook(() => useFetch('CHzlSGRvWPs', true));
// const videos = mockVideos;
// response.resolve({ json: () => ({ data: videos }) });

// await waitForNextUpdate();
// expect(result.current.videosRelated).toEqual({ data: videos });
// });

it('Getting an error during request', async () => {
global.fetch = jest.fn(() => {
return new Promise(() => {
const err = 'Network error';
throw err;
});
});

const { result, waitForNextUpdate } = renderHook(() => useFetch('CHzlSGRvWPs', true));
await waitForNextUpdate();
expect(result.current.error).toBe(true);
});
});
Loading