-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'staging' into ft-user-can-view-and-edit-own-profile-166…
…840973
- Loading branch information
Showing
69 changed files
with
1,567 additions
and
238 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,4 +12,6 @@ checks: | |
enabled: false | ||
identical-code: | ||
enabled: true | ||
|
||
method-complexity: | ||
config: | ||
threshold: 10 |
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
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,24 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import { shallow } from 'enzyme'; | ||
import Comments from '../src/components/Comments'; | ||
|
||
describe('Main Article', () => { | ||
let component; | ||
|
||
beforeEach(() => { | ||
component = shallow(<Comments />); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(component).toBeDefined(); | ||
}); | ||
|
||
it('renders a div tag', () => { | ||
expect(component.find('div').length).toBe(1); | ||
}); | ||
|
||
it('renders an h1 tag', () => { | ||
expect(component.find('h1').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,25 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import { shallow } from 'enzyme'; | ||
import CommentsBtn from '../src/components/SingleArticle/CommentsBtn'; | ||
|
||
|
||
describe('Single Article', () => { | ||
let component; | ||
|
||
beforeEach(() => { | ||
component = shallow(<CommentsBtn />); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(component).toBeDefined(); | ||
}); | ||
|
||
it('renders a div component', () => { | ||
expect(component.find('div').length).toBe(1); | ||
}); | ||
|
||
it('renders a Link component', () => { | ||
expect(component.find('Link').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,60 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import Enzyme, { shallow } from 'enzyme'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import { DraftArticles } from '../src/components/Dashboard/DraftArticles'; | ||
|
||
const mockStore = configureMockStore(); | ||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
describe('Draft Articles', () => { | ||
const props = { | ||
getAuthUserDraftArticles: jest.fn(), | ||
auth: { user: { id: 3 } }, | ||
userProfile: { | ||
draft: { | ||
articles: [ | ||
{ | ||
id: 1, | ||
title: 'title 1', | ||
imageUrl: 'http://img.com', | ||
body: 'I am the body', | ||
isDraft: true, | ||
Category: { | ||
name: 'Game', | ||
}, | ||
views: '34', | ||
|
||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
let app; | ||
let store; | ||
|
||
beforeEach(() => { | ||
store = mockStore(); | ||
app = shallow( | ||
<DraftArticles store={store} {...props} />, | ||
); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(app).toBeDefined(); | ||
}); | ||
|
||
it('gets all draft articles', () => { | ||
const articleContainer = app.find('.article-title'); | ||
expect(articleContainer).toHaveLength(1); | ||
expect(articleContainer.props().children).toEqual(props.userProfile.draft.articles[0].title); | ||
}); | ||
|
||
it('Click on pagination', () => { | ||
app.instance().paginate(2); | ||
const render = jest.spyOn(app.instance(), 'paginate'); | ||
expect(render).toHaveBeenCalledTimes(0); | ||
}); | ||
}); |
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
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 expect from 'expect'; | ||
import { shallow } from 'enzyme'; | ||
import MainArticle from '../src/components/SingleArticle/MainArticle'; | ||
import image from '../src/assets/articleImage.png'; | ||
|
||
describe('Main Article', () => { | ||
let component; | ||
|
||
const props = { | ||
views: 1, | ||
imageUrl: '', | ||
}; | ||
|
||
beforeEach(() => { | ||
component = shallow(<MainArticle {...props} />); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(component).toBeDefined(); | ||
}); | ||
|
||
it('renders three div tags', () => { | ||
expect(component.find('div').length).toBe(3); | ||
component.setProps({ views: 2 }); | ||
component.setProps({ imageUrl: image }); | ||
}); | ||
|
||
it('renders an h1 tag', () => { | ||
expect(component.find('h1').length).toBe(1); | ||
}); | ||
|
||
it('renders an Link tag', () => { | ||
expect(component.find('Link').length).toBe(1); | ||
}); | ||
|
||
it('renders a p tag', () => { | ||
expect(component.find('p').length).toBe(3); | ||
}); | ||
|
||
it('renders a span tag', () => { | ||
expect(component.find('span').length).toBe(3); | ||
}); | ||
|
||
it('renders an image tag', () => { | ||
expect(component.find('img').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,60 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import Enzyme, { shallow } from 'enzyme'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import { PublishedArticles } from '../src/components/Dashboard/PublishedArticles'; | ||
|
||
const mockStore = configureMockStore(); | ||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
describe('Published Articles', () => { | ||
const props = { | ||
getAuthUserPublishedArticles: jest.fn(), | ||
auth: { user: { id: 3 } }, | ||
userProfile: { | ||
published: { | ||
articles: [ | ||
{ | ||
id: 1, | ||
title: 'title 1', | ||
imageUrl: 'http://img.com', | ||
body: 'I am the body', | ||
isDraft: false, | ||
Category: { | ||
name: 'Game', | ||
}, | ||
views: '34', | ||
|
||
}, | ||
], | ||
}, | ||
}, | ||
}; | ||
|
||
let app; | ||
let store; | ||
|
||
beforeEach(() => { | ||
store = mockStore(); | ||
app = shallow( | ||
<PublishedArticles store={store} {...props} />, | ||
); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(app).toBeDefined(); | ||
}); | ||
|
||
it('gets all published articles', () => { | ||
const articleContainer = app.find('.article-title'); | ||
expect(articleContainer).toHaveLength(1); | ||
expect(articleContainer.props().children).toEqual(props.userProfile.published.articles[0].title); | ||
}); | ||
|
||
it('Click on pagination', () => { | ||
app.instance().paginate(2); | ||
const render = jest.spyOn(app.instance(), 'paginate'); | ||
expect(render).toHaveBeenCalledTimes(0); | ||
}); | ||
}); |
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,64 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import { shallow } from 'enzyme'; | ||
import Recommended from '../src/components/SingleArticle/Recommended'; | ||
import image from '../src/assets/articleImage.png'; | ||
|
||
describe('Main Article', () => { | ||
let component; | ||
|
||
const props = { | ||
allArticles: [{ | ||
title: 'Hello', | ||
article: { slug: 'hello-1', imageUrl: '' }, | ||
}, | ||
{ | ||
title: 'Hellos', | ||
article: { slug: 'hello-2', imageUrl: '' }, | ||
}, | ||
{ | ||
title: 'Helloey', | ||
article: { slug: 'hello-3', imageUrl: '' }, | ||
}], | ||
}; | ||
|
||
beforeEach(() => { | ||
component = shallow(<Recommended {...props} />); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(component).toBeDefined(); | ||
}); | ||
|
||
it('renders a div tag', () => { | ||
expect(component.find('div').length).toBe(2); | ||
}); | ||
|
||
it('renders an h3 tag', () => { | ||
expect(component.find('h3').length).toBe(1); | ||
}); | ||
|
||
it('renders three h4 tags', () => { | ||
expect(component.find('h4').length).toBe(3); | ||
}); | ||
|
||
it('renders three image tags', () => { | ||
expect(component.find('img').length).toBe(3); | ||
component.setProps({ | ||
allArticles: { | ||
0: { article: { slug: 'hello-1', imageUrl: image } }, | ||
1: { article: { slug: 'hello-2', imageUrl: image } }, | ||
2: { article: { slug: 'hello-3', imageUrl: image } }, | ||
}, | ||
}); | ||
}); | ||
|
||
it('renders three Link tags', () => { | ||
expect(component.find('Link').length).toBe(3); | ||
}); | ||
|
||
it('returns null', () => { | ||
component.setProps({ allArticles: [] }); | ||
expect(component).toEqual({}); | ||
}); | ||
}); |
Oops, something went wrong.