-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from andela/ft-article-crud-165412877
#165412877 Article CRUD
- Loading branch information
Showing
117 changed files
with
3,387 additions
and
148 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,18 +1,15 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
|
||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/ico.png" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<title>Authors Haven</title> | ||
</head> | ||
|
||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
</body> | ||
|
||
</html> | ||
<head> | ||
<meta charset="utf-8" /> | ||
<link rel="shortcut icon" href="%PUBLIC_URL%/ico.png" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1" /> | ||
<meta name="theme-color" content="#000000" /> | ||
<link rel="manifest" href="%PUBLIC_URL%/manifest.json" /> | ||
<title>Authors Haven</title> | ||
</head> | ||
<body> | ||
<noscript>You need to enable JavaScript to run this app.</noscript> | ||
<div id="root"></div> | ||
</body> | ||
</html> |
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,2 @@ | ||
URL.createObjectURL = jest.fn(file => file); | ||
export default URL; |
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,5 @@ | ||
export default (Object.article = { | ||
title: 'my title well done', | ||
description: 'description of the article: well', | ||
body: 'body of the article: well' | ||
}); |
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 @@ | ||
export default (Object.message = { message: 'article message' }); |
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,22 @@ | ||
export default (Object.articles = [ | ||
{ | ||
author: { username: 'nivelo', bio: null, image: null }, | ||
body: 'body', | ||
coverUrl: 'v1562366643/ninjas/ezzmjn0ak9b5gyzuzo6j.png', | ||
createdAt: '2019-07-05T22:43:57.384Z', | ||
description: 'ijihjhj', | ||
dislikes: null, | ||
favorited: false, | ||
favoritesCount: 0, | ||
id: 3, | ||
likes: null, | ||
rating: 0, | ||
readTime: '0', | ||
slug: 'how-to-conditionally-build-an-object-in-javascript-with-es6-m5mjxqor8sh', | ||
status: 'published', | ||
tagList: null, | ||
title: 'How to conditionally build an object in JavaScript with ES6', | ||
updatedAt: '2019-07-09T12:36:34.033Z', | ||
userId: 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
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 @@ | ||
export default (Object.errors = { message: 'can not updated article' }); |
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 @@ | ||
module.exports = 'test-file-stub'; |
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 @@ | ||
export default (Object.image = ['/img/image.jpg']); |
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 @@ | ||
export default (Object.imageErrors = { imageErrors: 'can not upload image' }); |
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
3 changes: 3 additions & 0 deletions
3
src/__tests__/actions/articles/__snapshots__/articles.test.js.snap
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<ArticleComponent /> should render a <CreateArticleComponent /> component 1`] = `ShallowWrapper {}`; |
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,24 @@ | ||
import React from 'react'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import thunk from 'react-thunk'; | ||
import { Provider } from 'react-redux'; | ||
import article from '../../../__mocks__/article'; | ||
import { Article as ArticleComponent } from '../../../components/Articles/Article/Article'; | ||
import { shallow, mount } from '../../../../config/enzymeConfig'; | ||
|
||
describe('<ArticleComponent />', () => { | ||
const props = { | ||
errors: { error: ['12'] }, | ||
article: { | ||
title: 'Hello John Doe', | ||
description: 'John Doe, Mocker', | ||
body: 'body of the article' | ||
}, | ||
fetchOneArticle: jest.fn() | ||
}; | ||
|
||
const component = shallow(<ArticleComponent {...props} />); | ||
it('should render a <CreateArticleComponent /> component ', () => { | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
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,13 @@ | ||
import { createPost } from '../../../actions/articles'; | ||
import article from '../../../__mocks__/article'; | ||
|
||
const dispatch = jest.fn(action => action); | ||
|
||
describe('Create article', () => { | ||
test('returns article information', async () => { | ||
const result = createPost(article)(dispatch); | ||
expect(result).toHaveProperty('type'); | ||
expect(result).toHaveProperty('payload'); | ||
expect(result.payload.data).toEqual(article); | ||
}); | ||
}); |
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,12 @@ | ||
import { deleteArticle } from '../../../actions/articles'; | ||
import article from '../../../__mocks__/article'; | ||
|
||
const dispatch = jest.fn(action => action); | ||
|
||
describe('delete article', () => { | ||
it('returns delete article information', async () => { | ||
const result = deleteArticle({ slug: 'slug-slug' })(dispatch); | ||
expect(result).toHaveProperty('type'); | ||
expect(result).toHaveProperty('payload'); | ||
}); | ||
}); |
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,13 @@ | ||
import { editPost } from '../../../actions/articles'; | ||
import article from '../../../__mocks__/article'; | ||
|
||
const dispatch = jest.fn(action => action); | ||
|
||
describe('edit article', () => { | ||
it('returns article information', async () => { | ||
const result = editPost({ article })(dispatch); | ||
expect(result).toHaveProperty('type'); | ||
expect(result).toHaveProperty('payload'); | ||
expect(result.payload.data).toEqual(article); | ||
}); | ||
}); |
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,12 @@ | ||
import { publishArticle } from '../../../actions/articles'; | ||
import article from '../../../__mocks__/article'; | ||
|
||
const dispatch = jest.fn(action => action); | ||
|
||
describe('publish article', () => { | ||
it('returns publish information', async () => { | ||
const result = publishArticle({ slug: 'slug-slug' })(dispatch); | ||
expect(result).toHaveProperty('type'); | ||
expect(result).toHaveProperty('payload'); | ||
}); | ||
}); |
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,11 @@ | ||
import { unpublishArticle } from '../../../actions/articles'; | ||
|
||
const dispatch = jest.fn(action => action); | ||
|
||
describe('unpublish article', () => { | ||
it('returns unpublish information', async () => { | ||
const result = unpublishArticle({ slug: 'slug-slug' })(dispatch); | ||
expect(result).toHaveProperty('type'); | ||
expect(result).toHaveProperty('payload'); | ||
}); | ||
}); |
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,12 @@ | ||
import { uploadImage } from '../../../actions/images/images'; | ||
import article from '../../../__mocks__/article'; | ||
|
||
const dispatch = jest.fn(action => action); | ||
|
||
describe('upload image', () => { | ||
test('returns upload information', async () => { | ||
const result = uploadImage({ image: 'image.png' })(dispatch); | ||
expect(result).toHaveProperty('type'); | ||
expect(result).toHaveProperty('payload'); | ||
}); | ||
}); |
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,48 @@ | ||
import React from 'react'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { Provider } from 'react-redux'; | ||
import { mount } from '../../../config/enzymeConfig'; | ||
import Article from '../../components/Articles/Article/Article'; | ||
import PreviewArticle from '../../components/Profile/Articles/PreviewArticle'; | ||
import EditArticle from '../../components/Profile/Articles/EditArticle'; | ||
import CreateArticle from '../../components/Profile/Articles/CreateArticle'; | ||
import store from '../../__mocks__/store'; | ||
|
||
describe('<Article />', () => { | ||
test('Get one article', () => { | ||
const props = { match: { params: { slug: 'slug' } } }; | ||
const component = mount(<Provider store={store}> | ||
<MemoryRouter> | ||
<Article {...props} /> | ||
</MemoryRouter> | ||
</Provider>); | ||
expect(component).toHaveLength(1); | ||
}); | ||
test('Preview one article', () => { | ||
const props = { match: { params: { slug: 'slug' } } }; | ||
const component = mount(<Provider store={store}> | ||
<MemoryRouter> | ||
<PreviewArticle {...props} /> | ||
</MemoryRouter> | ||
</Provider>); | ||
expect(component).toHaveLength(1); | ||
}); | ||
test('Edit one article', () => { | ||
const props = { match: { params: { slug: 'slug' } } }; | ||
const component = mount(<Provider store={store}> | ||
<MemoryRouter> | ||
<EditArticle {...props} /> | ||
</MemoryRouter> | ||
</Provider>); | ||
expect(component).toHaveLength(1); | ||
}); | ||
test('Create one article', () => { | ||
const props = { match: { params: { slug: 'slug' } } }; | ||
const component = mount(<Provider store={store}> | ||
<MemoryRouter> | ||
<CreateArticle {...props} /> | ||
</MemoryRouter> | ||
</Provider>); | ||
expect(component).toHaveLength(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,25 @@ | ||
import React from 'react'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import thunk from 'react-thunk'; | ||
import { Provider } from 'react-redux'; | ||
import article from '../../../__mocks__/article'; | ||
import { Article } from '../../../components/Articles/Article/Article'; | ||
import { shallow } from '../../../../config/enzymeConfig'; | ||
|
||
describe('<Article />', () => { | ||
const props = { | ||
article: { | ||
id: 1, | ||
title: 'Hello John Doe', | ||
description: 'John Doe, Mocker', | ||
body: 'body of the article' | ||
}, | ||
match: { params: { slug: 'slug-slug-slug' } }, | ||
fetchOneArticle: jest.fn() | ||
}; | ||
|
||
const component = shallow(<Article {...props} />); | ||
it('should render a <Article /> component ', () => { | ||
expect(component).toMatchSnapshot(); | ||
}); | ||
}); |
17 changes: 17 additions & 0 deletions
17
src/__tests__/components/Articles/FeaturedArticles.test.js
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,17 @@ | ||
import React from 'react'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { Provider } from 'react-redux'; | ||
import { mount } from '../../../../config/enzymeConfig'; | ||
import FeaturedArticles from '../../../components/Articles/FeaturedArticles/FeaturedArticles'; | ||
import store from '../../../__mocks__/store'; | ||
|
||
describe('<FeaturedArticles />', () => { | ||
test('Get features articles', () => { | ||
const component = mount(<Provider store={store}> | ||
<MemoryRouter> | ||
<FeaturedArticles /> | ||
</MemoryRouter> | ||
</Provider>); | ||
expect(component).toHaveLength(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,17 @@ | ||
import React from 'react'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { Provider } from 'react-redux'; | ||
import { mount } from '../../../../config/enzymeConfig'; | ||
import Tags from '../../../components/Articles/Tags/Tags'; | ||
import store from '../../../__mocks__/store'; | ||
|
||
describe('<Tags />', () => { | ||
test('renders without crashing', () => { | ||
const component = mount(<Provider store={store}> | ||
<MemoryRouter> | ||
<Tags /> | ||
</MemoryRouter> | ||
</Provider>); | ||
expect(component).toHaveLength(1); | ||
}); | ||
}); |
3 changes: 3 additions & 0 deletions
3
src/__tests__/components/Articles/__snapshots__/Article.test.js.snap
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,3 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`<Article /> should render a <Article /> component 1`] = `ShallowWrapper {}`; |
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 configureMockStore from 'redux-mock-store'; | ||
import thunk from 'react-thunk'; | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { Provider } from 'react-redux'; | ||
import articles from '../../../__mocks__/articles'; | ||
import { mockStore, initialState } from '../../../__mocks__/store'; | ||
import ListOfArticles from '../../../components/Articles/ListOfArticles/ListOfArticles'; | ||
import { shallow, mount } from '../../../../config/enzymeConfig'; | ||
|
||
const props = { | ||
articles, | ||
getAllArticles: jest.fn() | ||
}; | ||
const store = mockStore({ | ||
...initialState, | ||
articles: { articles } | ||
}); | ||
describe('<ListOfArticles />', () => { | ||
it('should render a <ListOfArticles /> component ', () => { | ||
const component = mount(<Provider store={store}> | ||
<MemoryRouter> | ||
<ListOfArticles /> | ||
</MemoryRouter> | ||
</Provider>); | ||
}); | ||
}); |
Oops, something went wrong.