-
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.
ft(createTeamTest): Add test for create-team page
- add test for notification popup - add test for createTeam action - change visualFeedback extension to jsx [Finishes #161157079]
- Loading branch information
Showing
11 changed files
with
283 additions
and
202 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
41 changes: 27 additions & 14 deletions
41
client/src/tests/__mocks__/__mockData__/createTeamMock.js
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,15 +1,28 @@ | ||
export const createTeamMock = { | ||
createTeamResponse: { | ||
team: { | ||
containsYou: true, | ||
} | ||
}, | ||
teamInfo: { | ||
name: 'ghoulie', | ||
description: 'lagos cohort 32', | ||
private: 'private', | ||
integrations: { | ||
github: [] | ||
} | ||
const createTeamMock = { | ||
createTeamResponse: { | ||
data: { | ||
team: { | ||
containsYou: true, | ||
id: 2 | ||
} | ||
} | ||
} | ||
|
||
}, | ||
teamInfoData: { | ||
name: 'ghoulie', | ||
description: 'lagos cohort 32', | ||
private: 'private', | ||
integrations: { | ||
github: ['ah-ghoulie', 'ghoulie-frontend'], | ||
pt: ['ah-ghoulie'] | ||
} | ||
}, | ||
createTeamData: { | ||
name: 'ghoulie', | ||
description: 'lagos cohort 32', | ||
private: 'private' | ||
} | ||
|
||
}; | ||
|
||
export default createTeamMock; |
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,38 @@ | ||
import expect from 'expect'; | ||
import configureMockStore from 'redux-mock-store'; | ||
import thunk from 'redux-thunk'; | ||
|
||
import { createTeam } from '../../../../redux/actions/teams'; | ||
import createTeamMock from '../../../__mocks__/__mockData__/createTeamMock'; | ||
|
||
const middlewares = [thunk]; | ||
const mockStore = configureMockStore(middlewares); | ||
|
||
describe('Create Team actions', () => { | ||
beforeAll(() => { | ||
localStorage.setItem('aTeamsToken', 'eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJlbWFpbCI6Im9sdXdhZmVtaS5hZGVrdW5sZUBhbmRlbGEuY29tIiwiaWF0IjoxNTM5MTgzNDQ0fQ.y40N5vI3d6BvOjPSl98vSK8l7D7sSD42Ta9daEdRtC0'); | ||
}); | ||
beforeEach(() => { | ||
mock.reset(); | ||
}); | ||
|
||
it('creates a new team with valid form inputs', async () => { | ||
const { createTeamResponse, teamInfoData, createTeamData } = createTeamMock; | ||
const expectedActions = [{ "name": "OLUWAFEMI", "payload": true, "type": "[auth]: check if user is logged in" }, | ||
{ "payload": true, "type": "[ui]: show preloader" }, { "payload": false, "type": "[ui]: show preloader" }, | ||
{ | ||
"payload": { | ||
"github": [{ "created": false, "name": "ah-ghoulie" }, { "created": false, "name": "ghoulie-frontend" }], | ||
"pt": [{ "created": false, "name": "ah-ghoulie" }], | ||
"team": [{ "created": true, "name": "ghoulie" }] | ||
}, | ||
"type": "SHOW_RESPONSE" | ||
}]; | ||
const store = mockStore({}); | ||
await mock | ||
.onPost('teams', createTeamData) | ||
.reply(201, { response: createTeamResponse }); | ||
await store.dispatch(createTeam(teamInfoData)); | ||
expect(store.getActions()).toEqual(expectedActions); | ||
}); | ||
}); |
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 { shallow } from 'enzyme'; | ||
import VisualFeedback from '../../toasts/VisualFeedback'; | ||
|
||
describe('CreateTeam Form test-suite', () => { | ||
const props = { | ||
modalState: jest.fn(), | ||
isModalOpened: false, | ||
response: { | ||
team: [{ created: true, name: 'ghoulies' }] | ||
} | ||
}; | ||
|
||
it('renders properly', () => { | ||
const VisualFeedbackWrapper = shallow(<VisualFeedback {...props} />); | ||
expect(VisualFeedbackWrapper.exists()).toBeTruthy(); | ||
}); | ||
|
||
it('should close the modal when ok button is clicked', () => { | ||
const VisualFeedbackWrapper = shallow(<VisualFeedback {...props} />); | ||
VisualFeedbackWrapper.find('.btn').simulate('click'); | ||
expect(props.modalState).toHaveBeenCalled(); | ||
}); | ||
}); |
Oops, something went wrong.