-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
32 changed files
with
909 additions
and
143 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
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,44 @@ | ||
import moxios from 'moxios'; | ||
import { makeMockStore } from '@Utils/index'; | ||
import { | ||
followUser, | ||
followUserSuccess, | ||
followUserFailure, | ||
followUserStart, | ||
} from '../followActions'; | ||
|
||
const store = makeMockStore({}); | ||
|
||
|
||
describe('testing redux actions', () => { | ||
beforeEach(() => { | ||
moxios.install(); | ||
}); | ||
afterEach(() => { | ||
moxios.uninstall(); | ||
}); | ||
it('should follow a user', async () => { | ||
const res = await store.dispatch(followUserStart()); | ||
expect(res.type).toEqual('FOLLOW_USER_START'); | ||
}); | ||
|
||
it('should follow a user', async () => { | ||
const res = await store.dispatch(followUserSuccess()); | ||
expect(res.type).toEqual('FOLLOW_USER_SUCCESS'); | ||
}); | ||
|
||
it('should follow a user', async () => { | ||
const res = await store.dispatch(followUserFailure()); | ||
expect(res.type).toEqual('FOLLOW_USER_FAILURE'); | ||
}); | ||
|
||
it('should follow a user', async () => { | ||
const res = await store.dispatch(followUser()); | ||
expect(res.type).toEqual('FOLLOW_USER_FAILURE'); | ||
}); | ||
it('should follow a user', async () => { | ||
const res = await store.getActions(); | ||
expect(res[1].type).toEqual('FOLLOW_USER_SUCCESS'); | ||
expect(res[1].payload).toEqual(undefined); | ||
}); | ||
}); |
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,44 @@ | ||
import moxios from 'moxios'; | ||
import { makeMockStore } from '@Utils/index'; | ||
import { | ||
unFollowUser, | ||
unfollowUserSuccess, | ||
unfollowUserFailure, | ||
unfollowUserStart, | ||
} from '../unfollowActions'; | ||
|
||
const store = makeMockStore({}); | ||
|
||
|
||
describe('testing redux actions', () => { | ||
beforeEach(() => { | ||
moxios.install(); | ||
}); | ||
afterEach(() => { | ||
moxios.uninstall(); | ||
}); | ||
it('should follow a user', async () => { | ||
const res = await store.dispatch(unfollowUserStart()); | ||
expect(res.type).toEqual('UNFOLLOW_USER_START'); | ||
}); | ||
|
||
it('should follow a user', async () => { | ||
const res = await store.dispatch(unfollowUserSuccess()); | ||
expect(res.type).toEqual('UNFOLLOW_USER_SUCCESS'); | ||
}); | ||
|
||
it('should follow a user', async () => { | ||
const res = await store.dispatch(unfollowUserFailure()); | ||
expect(res.type).toEqual('UNFOLLOW_USER_FAILURE'); | ||
}); | ||
|
||
it('should follow a user', async () => { | ||
const res = await store.dispatch(unFollowUser()); | ||
expect(res.type).toEqual('UNFOLLOW_USER_FAILURE'); | ||
}); | ||
it('should follow a user', async () => { | ||
const res = await store.getActions(); | ||
expect(res[1].type).toEqual('UNFOLLOW_USER_SUCCESS'); | ||
expect(res[1].payload).toEqual(undefined); | ||
}); | ||
}); |
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 * as types from '@Actions/types'; | ||
import { axiosInstance } from '@Utils/'; | ||
|
||
export const followUserStart = () => ({ | ||
type: types.FOLLOW_USER_START, | ||
}); | ||
|
||
export const followUserSuccess = (payload) => ({ | ||
type: types.FOLLOW_USER_SUCCESS, | ||
payload, | ||
}); | ||
|
||
export const followUserFailure = (error) => ({ | ||
type: types.FOLLOW_USER_FAILURE, | ||
error, | ||
}); | ||
|
||
|
||
export const followUser = (username) => async (dispatch) => { | ||
dispatch(followUserStart()); | ||
try { | ||
const response = await axiosInstance.post(`/profiles/${username}/follow`); | ||
return dispatch(followUserSuccess(response.data.profile)); | ||
} catch (error) { | ||
return dispatch(followUserFailure(error.response.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
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,27 @@ | ||
import * as types from '@Actions/types'; | ||
import { axiosInstance } from '@Utils/'; | ||
|
||
export const unfollowUserStart = () => ({ | ||
type: types.UNFOLLOW_USER_START, | ||
}); | ||
|
||
export const unfollowUserSuccess = (payload) => ({ | ||
type: types.UNFOLLOW_USER_SUCCESS, | ||
payload, | ||
}); | ||
|
||
export const unfollowUserFailure = (error) => ({ | ||
type: types.UNFOLLOW_USER_FAILURE, | ||
error, | ||
}); | ||
|
||
|
||
export const unFollowUser = (username) => async (dispatch) => { | ||
dispatch(unfollowUserStart()); | ||
try { | ||
const response = await axiosInstance.delete(`/profiles/${username}/follow`); | ||
return dispatch(unfollowUserSuccess(response.data.profile)); | ||
} catch (error) { | ||
return dispatch(unfollowUserFailure(error.response.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
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
Oops, something went wrong.