Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
aa5bd0c
add redux, saga, styled-components and react-router dependencies
diego-d5000 Jul 7, 2018
3288f8d
delete css
diego-d5000 Jul 7, 2018
81ded12
add basic views and routing
diego-d5000 Jul 7, 2018
a341dfa
add mock data
diego-d5000 Jul 7, 2018
8eb20d2
add navbar and basic navigation
diego-d5000 Jul 7, 2018
b13dcd7
add base redux app structure reducers and actions
diego-d5000 Jul 7, 2018
780d29e
add base sagas and reducers for giphy api fetching
diego-d5000 Jul 8, 2018
bf91874
add styles to gif grid, add favorite button
diego-d5000 Jul 8, 2018
9788f65
modified giphyApi reducer and view to use map instead of a list
diego-d5000 Jul 8, 2018
6df2b9e
add reducers and actions for favorites view
diego-d5000 Jul 8, 2018
cd27d57
add search feature with api en Fome and with filter in Favorites
diego-d5000 Jul 8, 2018
bf99d1e
add infinite scroll in trendings gifs
diego-d5000 Jul 9, 2018
20e84df
remove api keys from source (old api keys are now unusable, no git hi…
diego-d5000 Jul 9, 2018
b07c01a
add infinite scroll delay
diego-d5000 Jul 9, 2018
7fe97c6
add enzyme snapshot serializer and dependencies to use jest with styl…
diego-d5000 Jul 11, 2018
8710e0f
add test for NavBar component and styled NavBar presentational comps
diego-d5000 Jul 11, 2018
16649f9
remove css index styles, added inject global styles (styled-components)
diego-d5000 Jul 12, 2018
b17336d
added ignored files to coverage report
diego-d5000 Jul 12, 2018
ca039d7
add sagas test
diego-d5000 Jul 12, 2018
f9a0649
add reducers test
diego-d5000 Jul 12, 2018
bc616b3
add actions test
diego-d5000 Jul 12, 2018
41bee37
add components test
diego-d5000 Jul 12, 2018
383eef9
add error boundaries to pages components
diego-d5000 Jul 12, 2018
276275d
add test to main App component
diego-d5000 Jul 12, 2018
c1bcb8f
add enhancer to persist favorites
diego-d5000 Jul 12, 2018
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.example
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
REACT_APP_GIPHY_API_KEY=OWyGqcD3SWfggMMzdErRe9yHvasf2BBq

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you shouldn't save the api key in the .env.example

@diego-d5000 diego-d5000 Jul 10, 2018

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's ok, it's just an example, It's a fake key haha

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh, ok haha nice.

1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

# misc
.DS_Store
.env
.env.local
.env.development.local
.env.test.local
Expand Down
25 changes: 22 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,27 @@
"dependencies": {
"react": "^16.2.0",
"react-dom": "^16.2.0",
"react-scripts": "1.1.1"
"react-redux": "^5.0.7",
"react-router-dom": "^4.3.1",
"react-scripts": "1.1.1",
"redux": "^4.0.0",
"redux-actions": "^2.4.0",
"redux-localstorage": "^0.4.1",
"redux-saga": "^0.16.0",
"styled-components": "^3.3.3"
},
"jest": {
"snapshotSerializers": [
"enzyme-to-json/serializer"
],
"collectCoverageFrom": [
"**/src/**/*.{js,jsx}",
"!**/src/registerServiceWorker.{js,jsx}"
"!**/src/**/setupTests.js",
"!**/src/index.js",
"!**/src/enhancers/*.js",
"!**/src/middleware/logger.js",
"!**/src/registerServiceWorker.js",
"!**/src/global.styled.js"
],
"coverageThreshold": {
"global": {
Expand All @@ -31,6 +46,10 @@
},
"devDependencies": {
"enzyme": "^3.3.0",
"enzyme-adapter-react-16": "^1.1.1"
"enzyme-adapter-react-16": "^1.1.1",
"enzyme-to-json": "^3.3.4",
"jest-enzyme": "^6.0.2",
"jest-styled-components": "^5.0.1",
"redux-devtools-extension": "^2.13.5"
}
}
3 changes: 3 additions & 0 deletions public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
-->
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">

<link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.1.0/css/all.css" integrity="sha384-lKuwvrZot6UHsBSfcMvOkWwlCMgc0TaWr+30HWe3a4ltaBwTZhyTEggF5tJv8tbt" crossorigin="anonymous">

<!--
Notice the use of %PUBLIC_URL% in the tags above.
It will be replaced with the URL of the `public` folder during the build.
Expand Down
28 changes: 0 additions & 28 deletions src/App.css

This file was deleted.

18 changes: 7 additions & 11 deletions src/App.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,15 @@
import React, { Component } from 'react';
import logo from './logo.svg';
import './App.css';
import { Route, Switch } from 'react-router-dom';
import Home from './components/Home';
import Favorites from './components/Favorites';

class App extends Component {
render() {
return (
<div className="App">
<header className="App-header">
<img src={logo} className="App-logo" alt="logo" />
<h1 className="App-title">Welcome to React</h1>
</header>
<p className="App-intro">
To get started, edit <code>src/App.js</code> and save to reload.
</p>
</div>
<Switch>
<Route exact path="/" component={Home} />
<Route path="/favorites" component={Favorites} />
</Switch>
);
}
}
Expand Down
10 changes: 10 additions & 0 deletions src/App.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import React from 'react';
import { shallow } from 'enzyme';
import App from './App';

describe('App', () => {
test('App', () => {
const appComponent = shallow(<App />);
expect(appComponent).toMatchSnapshot();
})
})
15 changes: 15 additions & 0 deletions src/__snapshots__/App.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`App App 1`] = `
<Switch>
<Route
component={[Function]}
exact={true}
path="/"
/>
<Route
component={[Function]}
path="/favorites"
/>
</Switch>
`;
28 changes: 28 additions & 0 deletions src/actions/__snapshots__/favorites.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`giphyApi Actions toggleFavoriteGif 1`] = `
Object {
"payload": Object {
"gif": Object {
"8FMLOqBX3TwBxnKbrA": Object {
"id": "8FMLOqBX3TwBxnKbrA",
"images": Object {
"fixed_width": Object {
"height": "112",
"mp4": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.mp4",
"mp4_size": "142753",
"size": "739715",
"url": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.gif",
"webp": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.webp",
"webp_size": "265118",
"width": "200",
},
},
"slug": "ellamai-ella-mai-bood-up-8FMLOqBX3TwBxnKbrA",
"type": "gif",
},
},
},
"type": "TOGGLE_FAVORITE_GIF",
}
`;
99 changes: 99 additions & 0 deletions src/actions/__snapshots__/giphyApi.test.js.snap
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`giphyApi Actions fetchTrendingGifs 1`] = `
Object {
"payload": Object {
"page": 0,
"search": "funny",
},
"type": "FETCH_TRENDING_GIFS",
}
`;

exports[`giphyApi Actions receiveNextPageTrendingGifs 1`] = `
Object {
"payload": Object {
"gifs": Object {
"7vzoRu05YJp2pFMd24": Object {
"id": "7vzoRu05YJp2pFMd24",
"images": Object {
"fixed_width": Object {
"height": "112",
"mp4": "https://media2.giphy.com/media/7vzoRu05YJp2pFMd24/200w.mp4",
"mp4_size": "68902",
"size": "361247",
"url": "https://media2.giphy.com/media/7vzoRu05YJp2pFMd24/200w.gif",
"webp": "https://media2.giphy.com/media/7vzoRu05YJp2pFMd24/200w.webp",
"webp_size": "122550",
"width": "200",
},
},
"slug": "ellamai-ella-mai-bood-up-7vzoRu05YJp2pFMd24",
"type": "gif",
},
"8FMLOqBX3TwBxnKbrA": Object {
"id": "8FMLOqBX3TwBxnKbrA",
"images": Object {
"fixed_width": Object {
"height": "112",
"mp4": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.mp4",
"mp4_size": "142753",
"size": "739715",
"url": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.gif",
"webp": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.webp",
"webp_size": "265118",
"width": "200",
},
},
"slug": "ellamai-ella-mai-bood-up-8FMLOqBX3TwBxnKbrA",
"type": "gif",
},
},
},
"type": "RECEIVE_NEXT_PAGE_TRENDING_GIFS",
}
`;

exports[`giphyApi Actions receiveTrendingGifs 1`] = `
Object {
"payload": Object {
"gifs": Object {
"7vzoRu05YJp2pFMd24": Object {
"id": "7vzoRu05YJp2pFMd24",
"images": Object {
"fixed_width": Object {
"height": "112",
"mp4": "https://media2.giphy.com/media/7vzoRu05YJp2pFMd24/200w.mp4",
"mp4_size": "68902",
"size": "361247",
"url": "https://media2.giphy.com/media/7vzoRu05YJp2pFMd24/200w.gif",
"webp": "https://media2.giphy.com/media/7vzoRu05YJp2pFMd24/200w.webp",
"webp_size": "122550",
"width": "200",
},
},
"slug": "ellamai-ella-mai-bood-up-7vzoRu05YJp2pFMd24",
"type": "gif",
},
"8FMLOqBX3TwBxnKbrA": Object {
"id": "8FMLOqBX3TwBxnKbrA",
"images": Object {
"fixed_width": Object {
"height": "112",
"mp4": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.mp4",
"mp4_size": "142753",
"size": "739715",
"url": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.gif",
"webp": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.webp",
"webp_size": "265118",
"width": "200",
},
},
"slug": "ellamai-ella-mai-bood-up-8FMLOqBX3TwBxnKbrA",
"type": "gif",
},
},
},
"type": "RECEIVE_TRENDING_GIFS",
}
`;
12 changes: 12 additions & 0 deletions src/actions/favorites.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import { createActions } from 'redux-actions';

const TOGGLE_FAVORITE_GIF = 'TOGGLE_FAVORITE_GIF';

const { toggleFavoriteGif } = createActions({
[TOGGLE_FAVORITE_GIF]: (gif) => ({ gif }),
});

export {
toggleFavoriteGif,
}

27 changes: 27 additions & 0 deletions src/actions/favorites.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import { toggleFavoriteGif } from './favorites';

describe('giphyApi Actions', () => {
const mockGifData = {
'8FMLOqBX3TwBxnKbrA': {
"type": "gif",
"id": "8FMLOqBX3TwBxnKbrA",
"slug": "ellamai-ella-mai-bood-up-8FMLOqBX3TwBxnKbrA",
"images": {
"fixed_width": {
"url": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.gif",
"width": "200",
"height": "112",
"size": "739715",
"mp4": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.mp4",
"mp4_size": "142753",
"webp": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.webp",
"webp_size": "265118"
}
}
}
};

test('toggleFavoriteGif', () => {
expect(toggleFavoriteGif(mockGifData)).toMatchSnapshot();
});
})
17 changes: 17 additions & 0 deletions src/actions/giphyApi.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import { createActions } from 'redux-actions';

const FETCH_TRENDING_GIFS = 'FETCH_TRENDING_GIFS';
const RECEIVE_TRENDING_GIFS = 'RECEIVE_TRENDING_GIFS';
const RECEIVE_NEXT_PAGE_TRENDING_GIFS = 'RECEIVE_NEXT_PAGE_TRENDING_GIFS';

const { fetchTrendingGifs, receiveTrendingGifs, receiveNextPageTrendingGifs } = createActions({
[FETCH_TRENDING_GIFS]: (search = '', page = 0) => ({ search, page }),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Beautiful stuff 👌

[RECEIVE_TRENDING_GIFS]: (gifs) => ({ gifs }),
[RECEIVE_NEXT_PAGE_TRENDING_GIFS]: (gifs) => ({ gifs }),
});

export {
fetchTrendingGifs,
receiveTrendingGifs,
receiveNextPageTrendingGifs,
}
52 changes: 52 additions & 0 deletions src/actions/giphyApi.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
import { receiveNextPageTrendingGifs, receiveTrendingGifs, fetchTrendingGifs } from './giphyApi';

describe('giphyApi Actions', () => {
const mockGifsData = {
'8FMLOqBX3TwBxnKbrA': {
"type": "gif",
"id": "8FMLOqBX3TwBxnKbrA",
"slug": "ellamai-ella-mai-bood-up-8FMLOqBX3TwBxnKbrA",
"images": {
"fixed_width": {
"url": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.gif",
"width": "200",
"height": "112",
"size": "739715",
"mp4": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.mp4",
"mp4_size": "142753",
"webp": "https://media2.giphy.com/media/8FMLOqBX3TwBxnKbrA/200w.webp",
"webp_size": "265118"
}
}
},
"7vzoRu05YJp2pFMd24": {
"type": "gif",
"id": "7vzoRu05YJp2pFMd24",
"slug": "ellamai-ella-mai-bood-up-7vzoRu05YJp2pFMd24",
"images": {
"fixed_width": {
"url": "https://media2.giphy.com/media/7vzoRu05YJp2pFMd24/200w.gif",
"width": "200",
"height": "112",
"size": "361247",
"mp4": "https://media2.giphy.com/media/7vzoRu05YJp2pFMd24/200w.mp4",
"mp4_size": "68902",
"webp": "https://media2.giphy.com/media/7vzoRu05YJp2pFMd24/200w.webp",
"webp_size": "122550"
}
}
}
};

test('fetchTrendingGifs', () => {
expect(fetchTrendingGifs('funny', 0)).toMatchSnapshot();
});

test('receiveTrendingGifs', () => {
expect(receiveTrendingGifs(mockGifsData)).toMatchSnapshot();
});

test('receiveNextPageTrendingGifs', () => {
expect(receiveNextPageTrendingGifs(mockGifsData)).toMatchSnapshot();
});
})
File renamed without changes
Loading