forked from villacoder/react-certification-2021
-
Notifications
You must be signed in to change notification settings - Fork 95
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
Mini-Challenge 4: State management #92
Open
AntonioSalazar
wants to merge
122
commits into
cvillanueva84:master
Choose a base branch
from
AntonioSalazar:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 80 commits
Commits
Show all changes
122 commits
Select commit
Hold shift + click to select a range
3ffa74d
created the Navbar folder that contains the Navbar component file, th…
e33026d
Removed styles and all of the content we had in the repo,
021f06e
working on the navbar component, changing css files to scss
6dfcafb
Adding general styles
e07d928
will start working on the sidebar menu
8ef2462
Refactoring the navbar, work in progress, sidebar has been created now
bbd7f3a
sidebar menu is ready, its working now
ab3eaa1
The navbar is almost finished, it is responsive already, it contains the
1e7606e
Navbar is now complete, all requested components have been added, navbar
4897a9e
Merge branch 'feature/navbar' into develop
87fd95e
Added a data folder in the utils folder that contains the mockup data…
5cdeaaa
removed unneeded code from the Home page
1804de6
videoList component is now ready
9466df7
videoList component has been finished now
3ad238d
Merge branch 'feature/home-view' into develop
64b82ee
changing scss files back to css files as per the recommendation of my…
834c9c9
working on the tests of the HomePage component
27f3bd9
testing the Layout component
6c26caa
testing of the Layout component is ready
5ecd674
Home component tests are ready
7b28b74
VideoList component tests are ready
7021901
Navbar tests are ready
2155a33
Created the search context, and using it in the navbar component so n…
2a43dbf
Working on the VideoList Provider, able to get 23 videos from the you…
1fe2bdd
Able to display videos from the youtube api
2041a58
Added React.lazy and suspense
17a158c
created the VideoDetails component, it already displays the selectd v…
4681482
refactored the code, I have moved the styled components to separate f…
40ed78e
I have created a useFetch custom hook for fetching data
13063be
I have added react lazy and suspense to the app component for it to w…
5ea2603
RecommendedVideos component is ready, able to display the videos that…
f841ca8
tests of the app
c538e60
Merge branch 'hooks'
334a9b4
stopped tracking env file
c3d4da9
the web app now scrolls to top when changing to another video
ffec758
test of the useFetch custom hooks has been completed
503a5b2
finished the testing for the Navbar
37e0579
RecommendedVideos tests have been finished
57385e9
finished with the tests for the second deliverable
3f6d704
Merge branch 'hooks'
1e6986a
started working with the useReducer functionality
e90ccef
Merge branch 'hooks'
8c338c0
fixing the tests that failed due to useReducer implementation
6c71b59
tests that where broken by the implementation of useReducer have been…
301694c
added some icons to the theme toggler
d3844ca
theme toggler is complete now
2499922
fixed the shadow box for light and dark mode
b949a3c
all test are passing now
a226286
fixed some styles that were not working on smaller screens
7cb7635
removed a console log
6c7ea56
did some changes to the jest config in the package.json file, deleted…
2269d15
fixed the input, it wont submit if no search term is typed into the i…
ea419da
all tests are now passing
7278591
changed the scss navbar file back to css file, made som quick fixes
83ae2c5
deleted the useFortune custome hooks as im not using it
1ff6905
deleting unused files
a9ba3a2
Merge branch 'context'
05b869c
working on the modal for the login functionality
a2a0137
styles have been applied to the Login Modal
790b97c
user authentication is now working correctly
a5e9174
logout functionality has been implemented now, its working fine
3476ee7
all tests are passing now, will be adding more as I add more function…
b59d261
added the like and dislike buttons, this buttons look ok on large an …
0ed7fa4
fixed the styles of the like and dislike buttons
2b1b1fe
I fixed an error I was having in the console about useEffect
2231307
working on the implementation of adding videos to favorites
eaa6839
removed a console.log
40e951a
removed a console log
937be38
able to store favorite videos in localStorage now
5cbfa70
added the like and dislike buttons, for a user to add a video to its …
925faf3
making some changes to the styles for the page to look ok on smaller …
879cfeb
working on the FavoritesList component and styles, able to display th…
6cb65dd
made some changes that wont allow the user to add the same video to f…
d20d67a
able to add to favorites now, fixed some issues that I had
44abc1b
able to display the FavoriteDetails and FavoriteList components
55183c6
the user will be able to add a video to its favorites only once
3164722
add the removeFromFavorites action to the VideoList Reducer, able to …
78d5c9f
merge of last changes
8280b22
fixed an issue on the favoritesList component
5385a3b
added a redirect file for netlify to catch the 404 page according to …
33ebe65
working on my mentors recommendations, I have renamed the component f…
a0f67e4
as per my mentor recommendation, I have reorganized the order of the …
cee2a4e
Working on another recommendation from my mentor, I have removed the …
e46b872
I have removed the hard coded colors in the styled Components and Im …
38092b0
functionality seems to be complete now, will be working on turning cl…
373da30
I have removed some files that I was not using, I have changed classe…
2a7699f
classes in the FavoriteDetailsComponent have been changed to styled c…
67545e3
working on the tests of the FavoriteDetails and FavoriteListComponent
3653bc6
Added the test to the FavoriteListComponent, the component wont show …
a1380bd
added some tests, all of the tests are passing now
b372276
I have changed all of the classes in the LoginModal component to styl…
78d6645
added tests to the VideoList Reducer actions
6e0e0c2
changed the classes in the RecommendedVideoComponent to styled compon…
72057e3
removing some files that im not using and changed css classes to styl…
7e394bf
updated snapshots changed some classes to styled components y the Nav…
01cb2d9
working on the tests of the login modal
1790559
added the test of the PrivateComponent
fb38cd9
removed commented code
bba2f79
added a transition property to the like btn
fd62121
as per my mentor recommendation I have refactored the custom Hook use…
7c3734c
refactored the code so it can work now with the changed I did to the …
90ed434
fixing some parts of the code that broke after refactoring the useFet…
a3475ee
all tests are passing now
d2d811a
fixing some code that was not working
3c11e96
checking that everything works in master
2040045
saving changes done
0784817
Merge branch 'master' into routing
6e07c66
trying to fix an issue when saving favorit videos
17464f4
added the test of the PrivateComponent
1236272
removed commented code
feeccfc
added a transition property to the like btn
b77c3e7
as per my mentor recommendation I have refactored the custom Hook use…
de248f3
refactored the code so it can work now with the changed I did to the …
6dc8b3e
fixing some parts of the code that broke after refactoring the useFet…
d3495aa
all tests are passing now
bcfc240
fixing some code that was not working
8583a34
saving changes done
0bcf0f9
trying to fix an issue when saving favorit videos
5eb6268
I spent 5 hours trying to fix a small mistake I did...I have finally …
74ea05f
I spent 5 hours trying to fix a small mistake I did...I have finally …
cfbdbea
As per my mentor recommendation I have moved the filter login from th…
9aab697
fixed the test, it is passing now
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
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 |
---|---|---|
|
@@ -13,6 +13,7 @@ | |
|
||
# misc | ||
.DS_Store | ||
**/*.env | ||
.env.local | ||
.env.development.local | ||
.env.test.local | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
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
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 |
---|---|---|
@@ -0,0 +1 @@ | ||
/* /index.html 200 |
Binary file not shown.
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
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 |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import { mount } from "enzyme"; | ||
import App from "../../components/App/App.component"; | ||
import Navbar from '../../components/Navbar/Navbar.component'; | ||
|
||
|
||
|
||
|
||
describe('tests of the App component', () => { | ||
let wrapper = mount(< App/>) | ||
|
||
test('should render the component correctly', () => { | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
test('should have a videoList Provider', () => { | ||
let videoListProvider = wrapper.find('VideoListProvider') | ||
expect(videoListProvider.length).toBe(1) | ||
}) | ||
|
||
test('should have a Navbar component', () => { | ||
let navbar = wrapper.find('Navbar') | ||
expect(navbar.length).toBe(1) | ||
}) | ||
|
||
test('should have a HomePage component', () => { | ||
let homePage = wrapper.find('HomePage') | ||
expect(homePage.length).toBe(1) | ||
}) | ||
|
||
}) |
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 |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import Layout from '../../components/Layout/Layout.component'; | ||
import Navbar from '../../components/Navbar/Navbar.component'; | ||
jest.mock('../../components/Navbar/Navbar.component', () => 'Navbar') | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hace falta un espacio entre la linea 4 y 5 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. listo, espacio agregado |
||
|
||
describe('Test of the Layout component', () => { | ||
let children = Navbar | ||
let wrapper = shallow( < Layout children={children} />) | ||
|
||
test('main container should be rendered correctly', () => { | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
test('main tag should contain the container className', () => { | ||
const mainContainer = wrapper.find('main') | ||
expect(mainContainer.hasClass('container')).toBe(true) | ||
}) | ||
|
||
test('Layout component should display the received props inside the main tag', () => { | ||
const mainTag = wrapper.find('main').text() | ||
expect(mainTag).toBe(children) | ||
}) | ||
|
||
|
||
}) |
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 |
---|---|---|
@@ -0,0 +1,76 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import Navbar from '../../components/Navbar/Navbar.component' | ||
import { VideoListContext } from '../../providers/VideoList/VideoList.provider'; | ||
import Context from '../../providers/Theme/Theme.provider' | ||
import { MemoryRouter } from 'react-router'; | ||
import AuthProvider, { useAuth } from '../../providers/Auth'; | ||
|
||
|
||
describe('Tests of the Navbar component', () => { | ||
|
||
const setSearch = jest.fn() | ||
const dispatch = jest.fn() | ||
const logout = jest.fn() | ||
const authenticated = true | ||
let wrapper; | ||
beforeEach(() => { | ||
jest.clearAllMocks(); | ||
wrapper = mount( | ||
<AuthProvider | ||
value={{ | ||
authenticated, | ||
logout | ||
}} | ||
> | ||
<Context.Provider | ||
value={{ | ||
dispatch | ||
}} | ||
> | ||
<VideoListContext.Provider | ||
value={{ | ||
setSearch | ||
}} | ||
> | ||
<MemoryRouter> | ||
<Navbar/> | ||
</MemoryRouter> | ||
</VideoListContext.Provider> | ||
</Context.Provider> | ||
</AuthProvider>) | ||
}) | ||
|
||
test('should render the Navbar component correctly', () => { | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
test('should have an styled input tag', () => { | ||
const styledInput = wrapper.find('InputText') | ||
const value = 'React!' | ||
styledInput.simulate('change', { | ||
target: { | ||
value | ||
} | ||
}) | ||
expect(styledInput.length).toBe(1) | ||
}) | ||
test('should post info on submit', () => { | ||
const formEventMocked = { preventDefault: setSearch }; | ||
wrapper.find('form').simulate('submit', formEventMocked); | ||
expect(wrapper.find('form')).toHaveLength(1); | ||
expect(formEventMocked.preventDefault).toHaveBeenCalledTimes(1) | ||
}) | ||
|
||
test('should call setSearch and clean the input text ', () => { | ||
const value = 'learn jest' | ||
wrapper.find('InputText').simulate('change', { target: {value}}) | ||
wrapper.find('form').simulate('submit', {preventDefault(){}}); | ||
expect(setSearch).toHaveBeenCalled() | ||
expect(wrapper.find('InputText').prop('value')).toBe('') | ||
|
||
}) | ||
|
||
|
||
}) | ||
|
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 |
---|---|---|
@@ -0,0 +1,33 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme'; | ||
import RecommendedVideos from '../../components/RecommendedVideos'; | ||
import {VideoListContext} from '../../providers/VideoList/VideoList.provider'; | ||
import { videosState } from '../mockData/videosList' | ||
import { MemoryRouter } from 'react-router'; | ||
|
||
|
||
describe('Tests of the RecommendedVideos component', () => { | ||
|
||
const wrapper = mount( | ||
<VideoListContext.Provider | ||
value={{ | ||
videosState | ||
}} | ||
> | ||
<MemoryRouter> | ||
< RecommendedVideos/> | ||
</MemoryRouter> | ||
</VideoListContext.Provider> | ||
|
||
) | ||
|
||
test('should render the component correctly', () => { | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
test('should display all of the videos passed', () => { | ||
let videos = wrapper.find('recommended-video__card') | ||
expect(videos.length).toBe(videos.length) | ||
}) | ||
|
||
}) |
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 |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import React from 'react'; | ||
import { mount } from 'enzyme/build'; | ||
import VideoDetails from '../../components/VideoDetails/VideoDetails.component'; | ||
import { MemoryRouter, Route } from 'react-router'; | ||
import { videosState } from '../mockData/videosList' | ||
import { VideoListContext } from '../../providers/VideoList/VideoList.provider'; | ||
|
||
describe('Tests of the VideoDetials component', () => { | ||
const wrapper = mount( | ||
<VideoListContext.Provider | ||
value={{videosState}} | ||
> | ||
<MemoryRouter | ||
initialEntries={['/video/Po3VwR_NNGk']} | ||
> | ||
<Route path="/video/:id" > | ||
<VideoDetails /> | ||
</Route> | ||
</MemoryRouter> | ||
</VideoListContext.Provider>) | ||
|
||
test('should display the component correctly', () => { | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
|
||
}) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Todos estas lineas vacias son innecesarias
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Listo, ya borre esas lineas