Skip to content

Commit

Permalink
ft-user-can-view-and-edit-own-profile
Browse files Browse the repository at this point in the history
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
Alpha1202 committed Sep 2, 2019
1 parent ae17efe commit 2f82182
Show file tree
Hide file tree
Showing 154 changed files with 10,946 additions and 6,622 deletions.
4 changes: 3 additions & 1 deletion .codeclimate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,6 @@ checks:
enabled: false
identical-code:
enabled: true

method-complexity:
config:
threshold: 10
4 changes: 3 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@
"rules": {
"react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
"react/no-unescaped-entities": 0,
"react/destructuring-assignment": 0
"react/destructuring-assignment": 0,
"import/prefer-default-export": 0,
"jsx-a11y/click-events-have-key-events": 0,
}
}
12 changes: 8 additions & 4 deletions _test_/App.spec.js
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);
});
});
1 change: 0 additions & 1 deletion _test_/ArticleActions.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import moxios from 'moxios';
import makeMockStore from './Utils/makeMockStore';
import { fetchResponseData, mockData } from './testData/articleData';

import ArticleActions from '../src/actions/ArticleActions';
import {
SET_LOADING,
Expand Down
4 changes: 2 additions & 2 deletions _test_/ArticleCard.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ describe('ArticleCard', () => {
text={text}
date={date}
readTime={time}
likeCount={likes}
likeCount={parseInt(likes, 10)}
viewCount={views}
count={2}
/>);
Expand All @@ -35,7 +35,7 @@ describe('ArticleCard', () => {
});

it('renders a div component', () => {
expect(app.find('div').length).toBe(4);
expect(app.find('div').length).toBe(3);
});

it('renders an img component', () => {
Expand Down
98 changes: 98 additions & 0 deletions _test_/ArticleLayout.spec.js
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();
});
});
});
76 changes: 0 additions & 76 deletions _test_/ArticleReducer.spec.js

This file was deleted.

63 changes: 63 additions & 0 deletions _test_/Articles.spec.js
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);
});
});
});
31 changes: 31 additions & 0 deletions _test_/ArticlesAction.spec.js
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([]);
});
});
24 changes: 24 additions & 0 deletions _test_/ArticlesReducer.spec.js
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',
});
});
});
Loading

0 comments on commit 2f82182

Please sign in to comment.