-
Notifications
You must be signed in to change notification settings - Fork 0
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
7 changed files
with
205 additions
and
36 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
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,73 @@ | ||
export const addMemberRequest = { | ||
userId: 2, | ||
teamId: 3, | ||
teamName: 'team', | ||
accounts: [ | ||
{ | ||
type: 'github_repo', | ||
name: 'github_repo', | ||
accountId: 4 | ||
} | ||
] | ||
}; | ||
|
||
export const addMemberResponse = | ||
{ | ||
type: 'github_repo', | ||
name: 'github_repo', | ||
invited: true, | ||
response: { | ||
data: { | ||
response: { | ||
invitedUser: { | ||
ok: true | ||
} | ||
} | ||
} | ||
} | ||
}; | ||
|
||
export const response = | ||
{ | ||
type: 'github_repo', | ||
name: 'github_repo', | ||
invited: true, | ||
data: { | ||
response: { | ||
invitedUser: { | ||
ok: true | ||
} | ||
} | ||
} | ||
}; | ||
|
||
export const expectedActions = [ | ||
{ | ||
name: "EZE", | ||
payload: true, | ||
type: "[auth]: check if user is logged in" | ||
}, | ||
{ | ||
payload: true, | ||
type: "[ui]: show preloader" | ||
}, | ||
{ | ||
payload: [ | ||
{ | ||
invited: true, | ||
name: "github_repo", | ||
type: "github_repo" | ||
}, | ||
{ | ||
invited: true, | ||
name: "team", | ||
type: "team" | ||
} | ||
], | ||
type: "[users]: add member to a team" | ||
}, | ||
{ | ||
payload: false, | ||
type: "[ui]: show preloader" | ||
} | ||
]; |
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,35 @@ | ||
import expect from 'expect'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
|
||
import { addMember } from '../../../../redux/actions/teams/members'; | ||
|
||
import { addMemberRequest, addMemberResponse, response, expectedActions } from '../../../__mocks__/__mockData__/memberMock'; | ||
|
||
|
||
const middlewares = [thunk]; | ||
const mockStore = configureMockStore(middlewares); | ||
|
||
describe('Add a new user to team accounts', () => { | ||
beforeAll(() => { | ||
localStorage.setItem('aTeamsToken', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6ImV6ZS5rZXZpbkBhbmRlbGEuY29tIiwiaWF0IjoxNTM5ODYxNDU2fQ._FOXQtpzUnwtbaP2-Fn6HOhFDZpsWmS3GPxmOVSAWdE'); | ||
}); | ||
beforeEach(() => { | ||
mock.reset(); | ||
}); | ||
|
||
it('Adds a user to a team accounts', async () => { | ||
const store = mockStore({}); | ||
|
||
await mock | ||
.onPost('teams/3/members/2', { role: 'developer' }) | ||
.reply(201, addMemberResponse); | ||
|
||
await mock | ||
.onPost('teams/3/accounts/4/members/2') | ||
.reply(201, response); | ||
|
||
await store.dispatch(addMember(addMemberRequest)); | ||
expect(store.getActions()).toEqual(expectedActions); | ||
}); | ||
}); |