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

Second Deliverable #82

Open
wants to merge 37 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
3ffa74d
created the Navbar folder that contains the Navbar component file, th…
Jul 18, 2021
e33026d
Removed styles and all of the content we had in the repo,
Jul 18, 2021
021f06e
working on the navbar component, changing css files to scss
Jul 19, 2021
6dfcafb
Adding general styles
Jul 19, 2021
e07d928
will start working on the sidebar menu
Jul 19, 2021
8ef2462
Refactoring the navbar, work in progress, sidebar has been created now
Jul 19, 2021
bbd7f3a
sidebar menu is ready, its working now
Jul 19, 2021
ab3eaa1
The navbar is almost finished, it is responsive already, it contains the
Jul 19, 2021
1e7606e
Navbar is now complete, all requested components have been added, navbar
Jul 20, 2021
4897a9e
Merge branch 'feature/navbar' into develop
Jul 20, 2021
87fd95e
Added a data folder in the utils folder that contains the mockup data…
Jul 20, 2021
5cdeaaa
removed unneeded code from the Home page
Jul 20, 2021
1804de6
videoList component is now ready
Jul 23, 2021
9466df7
videoList component has been finished now
Jul 23, 2021
3ad238d
Merge branch 'feature/home-view' into develop
Jul 23, 2021
64b82ee
changing scss files back to css files as per the recommendation of my…
Jul 23, 2021
834c9c9
working on the tests of the HomePage component
Jul 31, 2021
27f3bd9
testing the Layout component
Aug 2, 2021
6c26caa
testing of the Layout component is ready
Aug 2, 2021
5ecd674
Home component tests are ready
Aug 2, 2021
7b28b74
VideoList component tests are ready
Aug 2, 2021
7021901
Navbar tests are ready
Aug 2, 2021
2155a33
Created the search context, and using it in the navbar component so n…
Aug 3, 2021
2a43dbf
Working on the VideoList Provider, able to get 23 videos from the you…
Aug 3, 2021
1fe2bdd
Able to display videos from the youtube api
Aug 3, 2021
2041a58
Added React.lazy and suspense
Aug 4, 2021
17a158c
created the VideoDetails component, it already displays the selectd v…
Aug 4, 2021
4681482
refactored the code, I have moved the styled components to separate f…
Aug 5, 2021
40ed78e
I have created a useFetch custom hook for fetching data
Aug 5, 2021
13063be
I have added react lazy and suspense to the app component for it to w…
Aug 5, 2021
5ea2603
RecommendedVideos component is ready, able to display the videos that…
Aug 5, 2021
c3d4da9
the web app now scrolls to top when changing to another video
Aug 6, 2021
ffec758
test of the useFetch custom hooks has been completed
Aug 6, 2021
503a5b2
finished the testing for the Navbar
Aug 9, 2021
37e0579
RecommendedVideos tests have been finished
Aug 9, 2021
57385e9
finished with the tests for the second deliverable
Aug 9, 2021
1e6986a
started working with the useReducer functionality
Aug 10, 2021
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
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"plugins": ["prettier"],
"rules": {
"prettier/prettier": "error",
"react/jsx-filename-extension": "error",
// "react/jsx-filename-extension": "error",
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react-hooks/exhaustive-deps": "warn",
"import/no-unresolved": ["off", { "ignore": [".css$"] }],
"import/prefer-default-export": "off",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand Down
18,169 changes: 18,169 additions & 0 deletions package-lock.json

Large diffs are not rendered by default.

22 changes: 20 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,21 +6,32 @@
"@testing-library/jest-dom": "^5.11.4",
"@testing-library/react": "^10.4.9",
"@testing-library/user-event": "^12.1.3",
"dotenv": "^10.0.0",
"enzyme": "^3.11.0",
"enzyme-adapter-react-16": "^1.15.6",
"enzyme-to-json": "^3.6.2",
"node-sass": "^4.14.1",
"react": "^16.13.1",
"react-dom": "^16.13.1",
"react-icons": "^4.2.0",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"react-scripts": "3.4.3"
"react-scripts": "3.4.3",
"react-spinners": "^0.11.0",
"styled-components": "^5.3.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"test:coverage": "npm run test -- --coverage",
"eject": "react-scripts eject",
"lint": "eslint ./src --ext .js,.jsx",
"lint:fix": "eslint ./src --ext .js,.jsx --fix"
},
"devDependencies": {
"@emotion/react": "^11.4.0",
"@testing-library/react-hooks": "^7.0.1",
"eslint-config-airbnb": "^18.2.0",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-eslint-comments": "^3.2.0",
Expand All @@ -30,9 +41,11 @@
"eslint-plugin-react": "^7.20.6",
"eslint-plugin-react-hooks": "^4.1.0",
"husky": "^4.2.5",
"jest-styled-components": "^7.0.5",
"lint-staged": "^10.2.13",
"prettier": "^2.1.1",
"pretty-quick": "^3.0.0"
"pretty-quick": "^3.0.0",
"react-test-renderer": "^16.9.0"
},
"browserslist": {
"production": [
Expand All @@ -57,5 +70,10 @@
"hooks": {
"pre-commit": "lint-staged"
}
},
"jest": {
"collectCoverageFrom": [
"src/Tests/*.js"
]
}
}
Binary file modified public/favicon.ico
Binary file not shown.
17 changes: 16 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,22 @@
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`.
-->
<title>React App</title>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"
/>

<title>YouTube clone App</title>
</head>
<body>
<noscript>You need to enable JavaScript to run this app.</noscript>
Expand Down
26 changes: 26 additions & 0 deletions src/Tests/components/Layout.test.js
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')

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)
})


})
55 changes: 55 additions & 0 deletions src/Tests/components/Navbar.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import React from 'react';
import { mount } from 'enzyme';
import Navbar from '../../components/Navbar/Navbar.component'
import { VideoListContext } from '../../providers/VideoList/VideoList.provider';
import { MemoryRouter } from 'react-router';

describe('Tests of the Navbar component', () => {

const setSearch = jest.fn()
let wrapper;
beforeEach(() => {
jest.clearAllMocks();
wrapper = mount(
<VideoListContext.Provider
value={{
setSearch
}}
>
<MemoryRouter>
<Navbar/>
</MemoryRouter>
</VideoListContext.Provider>)
});

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', () => {
wrapper.find('form').simulate('submit', {preventDefault(){}});
expect(setSearch).toHaveBeenCalled()
})

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('')

})


})

32 changes: 32 additions & 0 deletions src/Tests/components/RecommendedVideos.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import React from 'react';
import { mount } from 'enzyme';
import RecommendedVideos from '../../components/RecommendedVideos';
import {VideoListContext} from '../../providers/VideoList/VideoList.provider.jsx';
import { videoList as videos} from '../mockData/videosList'
import { MemoryRouter } from 'react-router';

describe('Tests of the RecommendedVideos component', () => {

const wrapper = mount(
<VideoListContext.Provider
value={{
videos
}}
>
<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)
})

})
27 changes: 27 additions & 0 deletions src/Tests/components/VideoDetails.test.js
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 { videoList as videos } from '../mockData/videosList'
import { VideoListContext } from '../../providers/VideoList/VideoList.provider';

describe('Tests of the VideoDetials component', () => {
const wrapper = mount(
<VideoListContext.Provider
value={{videos}}
>
<MemoryRouter
initialEntries={['/video/Po3VwR_NNGk']}
>
<Route path="/video/:id" >
<VideoDetails />
</Route>
</MemoryRouter>
</VideoListContext.Provider>)

test('should display the component correctly', () => {
expect(wrapper).toMatchSnapshot()
})


})
79 changes: 79 additions & 0 deletions src/Tests/components/VideoList.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
import React from 'react';
import { shallow } from 'enzyme';
import VideoList from '../../components/VideoList/VideoList.component';

describe('Tests of the VideoList component', () => {

const data = {
"kind": "youtube#searchResult",
"etag": "_PVKwNJf_qw9nukFeRFOtQ837o0",
"id": {
"kind": "youtube#channel",
"videoId": "UCPGzT4wecuWM0BH9mPiulXg"
},
"snippet": {
"publishedAt": "2014-09-27T01:39:18Z",
"channelId": "UCPGzT4wecuWM0BH9mPiulXg",
"title": "Wizeline",
"description": "Wizeline transforms how teams build technology. Its customers accelerate the delivery of innovative products with proven solutions, which combine Wizeline's ...",
"thumbnails": {
"default": {
"url": "https://yt3.ggpht.com/ytc/AAUvwnighSReQlmHl_S_vSfvnWBAG5Cw4A0YxtE0tm5OpQ=s88-c-k-c0xffffffff-no-rj-mo"
},
"medium": {
"url": "https://yt3.ggpht.com/ytc/AAUvwnighSReQlmHl_S_vSfvnWBAG5Cw4A0YxtE0tm5OpQ=s240-c-k-c0xffffffff-no-rj-mo"
},
"high": {
"url": "https://yt3.ggpht.com/ytc/AAUvwnighSReQlmHl_S_vSfvnWBAG5Cw4A0YxtE0tm5OpQ=s800-c-k-c0xffffffff-no-rj-mo"
}
},
"channelTitle": "Wizeline",
"liveBroadcastContent": "upcoming",
"publishTime": "2014-09-27T01:39:18Z"
}
}

const wrapper = shallow(< VideoList video={data}/>)
test('should render the VideoList component', () => {
expect(wrapper).toMatchSnapshot()
})


test('should contain the VideoCardDiv styled component', () => {
expect(wrapper.find('VideoCardDiv').length).toEqual(1);
})

test('should contain the VideoImageDiv styled component', () => {
expect(wrapper.find('VideoImageDiv').length).toEqual(1);
})

test('should contain the TitleSpan styled component', () => {
expect(wrapper.find('TitleSpan').length).toEqual(1);
})

test('should contain the DescriptionSpan styled component', () => {
expect(wrapper.find('DescriptionSpan').length).toEqual(1);
})

test('VideoImageDiv background Image should be the thumbnails.medium.url prop', () => {
const imgDiv = wrapper.find('VideoImageDiv')
expect(imgDiv.prop('style').backgroundImage).toBe(`url(${data.snippet.thumbnails.medium.url})`)
})


test('Title Span styled component should display the title prop', () => {
const titleSpan = wrapper.find('TitleSpan')
expect(titleSpan.text()).toBe(data.snippet.title)
})

test('Title Span styled component should display the title prop', () => {
const titleSpan = wrapper.find('TitleSpan')
expect(titleSpan.text()).toBe(data.snippet.title)
})

test('Description Span styled component should display the description prop', () => {
const descriptionSpan = wrapper.find('DescriptionSpan')
expect(descriptionSpan.text()).toBe(data.snippet.description)
})
})

9 changes: 9 additions & 0 deletions src/Tests/components/__snapshots__/Layout.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`Test of the Layout component main container should be rendered correctly 1`] = `
<main
className="container"
>
Navbar
</main>
`;
Loading