-
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.
ft-user-can-view-and-edit-own-profile
create view authenticated user profile fetch user profile api fetch user followers api fetch user followee api fetch user article api fetch user published article api fetch user draft article api fetch user update profile api create edit profile form [Finishes #166840973]
- Loading branch information
Showing
154 changed files
with
10,946 additions
and
6,622 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,31 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import { shallow } from 'enzyme'; | ||
import Enzyme, { shallow } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
import App from '../src/components/App'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
describe('App', () => { | ||
let app; | ||
const props = localStorage.getItem('jwtToken'); | ||
|
||
beforeEach(() => { | ||
app = shallow(<App />); | ||
app = shallow(<App {...props} />); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(app).toBeDefined(); | ||
}); | ||
|
||
it('renders a div component', () => { | ||
expect(app.find('div').length).toBe(1); | ||
expect(app.find('div').length).toBe(0); | ||
}); | ||
|
||
it('renders a Switch component', () => { | ||
expect(app.find('Switch').length).toBe(1); | ||
}); | ||
it('renders a Route component', () => { | ||
expect(app.find('Route').length).toBe(9); | ||
expect(app.find('Route').length).toBe(13); | ||
}); | ||
}); |
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,98 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import ArticleLayout from '../src/components/articleLayout/index'; | ||
|
||
describe('Article Layout', () => { | ||
describe('When no article found', () => { | ||
let app; | ||
const article = { | ||
allArticles: [ | ||
'No Article Found', | ||
], | ||
}; | ||
|
||
beforeEach(() => { | ||
app = shallow(<ArticleLayout article={article} />); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(app).toBeDefined(); | ||
}); | ||
|
||
it('Check for div', () => { | ||
expect(app.find('div').length).toBe(1); | ||
}); | ||
}); | ||
|
||
describe('Load articles', () => { | ||
let app; | ||
const article = { | ||
allArticles: [ | ||
{ | ||
article: { | ||
id: 3, | ||
title: 'Article 3', | ||
slug: 'article', | ||
description: '', | ||
body: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry', | ||
imageUrl: '', | ||
isDraft: true, | ||
views: 21, | ||
read: 21, | ||
readRatio: 0, | ||
userId: 1, | ||
catId: 1, | ||
Category: { | ||
id: 1, | ||
name: 'Education', | ||
}, | ||
User: { | ||
id: 1, | ||
firstName: null, | ||
lastName: null, | ||
userName: 'Alpha', | ||
bio: null, | ||
imageUrl: null, | ||
}, | ||
}, | ||
}, | ||
{ | ||
article: { | ||
id: 2, | ||
title: 'Article 2', | ||
slug: 'article', | ||
description: '', | ||
body: 'Lorem Ipsum is simply dummy text of the printing and typesetting industry.', | ||
imageUrl: '', | ||
isDraft: true, | ||
views: 4, | ||
read: 4, | ||
readRatio: 0, | ||
userId: 1, | ||
catId: 1, | ||
Category: { | ||
id: 1, | ||
name: 'Education', | ||
}, | ||
User: { | ||
id: 1, | ||
firstName: null, | ||
lastName: null, | ||
userName: 'Alpha', | ||
bio: null, | ||
imageUrl: null, | ||
}, | ||
}, | ||
}, | ||
], | ||
}; | ||
|
||
beforeEach(() => { | ||
app = shallow(<ArticleLayout article={article} />); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(app).toBeDefined(); | ||
}); | ||
}); | ||
}); |
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
import React from 'react'; | ||
import expect from 'expect'; | ||
import Enzyme, { shallow } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
|
||
import { GetAllArticles } from '../src/views/Articles'; | ||
|
||
Enzyme.configure({ adapter: new Adapter() }); | ||
|
||
describe('Articles', () => { | ||
describe('', () => { | ||
let app; | ||
const props = { | ||
paginate: jest.fn(), | ||
getAllArticles: jest.fn(), | ||
articles: { | ||
isLoading: false, | ||
articles: [ | ||
{ | ||
id: 1, | ||
title: 'title 1', | ||
imageUrl: 'http://img.com', | ||
body: 'I am the body', | ||
Category: { | ||
name: 'Game', | ||
}, | ||
views: '34', | ||
}, | ||
{ | ||
id: 2, | ||
title: 'title 2', | ||
imageUrl: 'http://img.com', | ||
body: 'I am the body 2', | ||
Category: { | ||
name: 'Game', | ||
}, | ||
views: '34', | ||
}, | ||
], | ||
}, | ||
}; | ||
|
||
beforeEach(() => { | ||
app = shallow(<GetAllArticles {...props} />); | ||
}); | ||
|
||
it('renders successfully', () => { | ||
expect(app).toBeDefined(); | ||
}); | ||
|
||
it('renders a div component', () => { | ||
expect(app.find('div').length).toBe(2); | ||
}); | ||
|
||
it('contains a paginate method', () => { | ||
const data = { | ||
selected: 2, | ||
}; | ||
const inst = app.instance(); | ||
inst.paginate(data); | ||
}); | ||
}); | ||
}); |
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,31 @@ | ||
import '@babel/polyfill'; | ||
import moxios from 'moxios'; | ||
import thunk from 'redux-thunk'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import mockArticle from '../src/utils/mockStore'; | ||
import getAllArticles from '../src/actions/articlesAction'; | ||
import axios from '../src/config/axiosInstance'; | ||
import { FETCH_ALL_ARTICLE } from '../src/actions/types'; | ||
|
||
const mockStore = configureMockStore([thunk]); | ||
let store = mockStore(); | ||
const { mockArticleResponse } = mockArticle; | ||
|
||
describe('Get All Articles', () => { | ||
beforeEach(() => { | ||
moxios.install(axios); | ||
store.clearActions(); | ||
}); | ||
|
||
afterEach(() => moxios.uninstall(axios)); | ||
it('Returns articles', async () => { | ||
await moxios.stubRequest('https://ah-nyati-backend-staging.herokuapp.com/api/v1/articles', { | ||
status: 200, | ||
response: mockArticleResponse, | ||
}); | ||
|
||
store = mockStore({}); | ||
await store.dispatch(getAllArticles()); | ||
expect(store.getActions()).toEqual([]); | ||
}); | ||
}); |
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 reducer from '../src/reducers/articlesReducer'; | ||
import { FETCH_ALL_ARTICLE } from '../src/actions/types'; | ||
|
||
describe('Login reducer', () => { | ||
const initState = { | ||
isLoading: true, | ||
articles: '', | ||
}; | ||
|
||
it('should return the initial state', () => { | ||
expect(reducer(undefined, {})).toEqual(initState); | ||
}); | ||
|
||
it('should successfully store articles on store', () => { | ||
expect(reducer(initState, { | ||
type: FETCH_ALL_ARTICLE, | ||
payload: 'articles', | ||
})).toEqual({ | ||
...initState, | ||
isLoading: false, | ||
articles: 'articles', | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.