forked from mattermost/mattermost-webapp
-
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.
Migrate get_team_invite_link_modal.jsx to be pure and use Redux (matt…
…ermost#209) * Migrate get team invite link modal to be pure and use redux * Add component tests * More component test
- Loading branch information
Showing
5 changed files
with
104 additions
and
13 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import {connect} from 'react-redux'; | ||
|
||
import {getCurrentTeam} from 'mattermost-redux/selectors/entities/teams'; | ||
import {getConfig} from 'mattermost-redux/selectors/entities/general'; | ||
|
||
import GetTeamInviteLinkModal from './get_team_invite_link_modal.jsx'; | ||
|
||
function mapStateToProps(state, ownProps) { | ||
return { | ||
...ownProps, | ||
currentTeam: getCurrentTeam(state), | ||
config: getConfig(state) | ||
}; | ||
} | ||
|
||
export default connect(mapStateToProps)(GetTeamInviteLinkModal); |
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
21 changes: 21 additions & 0 deletions
21
...ponents/get_team_invite_link_modal/__snapshots__/get_team_invite_link_modal.test.jsx.snap
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,21 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`components/GetTeamInviteLinkModal should match snapshot when user creation is disabled 1`] = ` | ||
<GetLinkModal | ||
helpText="User creation has been disabled for your team. Please ask your team administrator for details." | ||
link="null/signup_user_complete/?id=invite_id" | ||
onHide={[Function]} | ||
show={false} | ||
title="Team Invite Link" | ||
/> | ||
`; | ||
|
||
exports[`components/GetTeamInviteLinkModal should match snapshot when user creation is enabled 1`] = ` | ||
<GetLinkModal | ||
helpText="Send teammates the link below for them to sign-up to this team site. The Team Invite Link can be shared with multiple teammates as it does not change unless it's regenerated in Team Settings by a Team Admin." | ||
link="null/signup_user_complete/?id=invite_id" | ||
onHide={[Function]} | ||
show={false} | ||
title="Team Invite Link" | ||
/> | ||
`; |
44 changes: 44 additions & 0 deletions
44
tests/components/get_team_invite_link_modal/get_team_invite_link_modal.test.jsx
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 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See License.txt for license information. | ||
|
||
import React from 'react'; | ||
import {shallow} from 'enzyme'; | ||
|
||
import GetTeamInviteLinkModal from 'components/get_team_invite_link_modal/get_team_invite_link_modal.jsx'; | ||
import GetLinkModal from 'components/get_link_modal.jsx'; | ||
|
||
describe('components/GetTeamInviteLinkModal', () => { | ||
test('should match snapshot when user creation is enabled', () => { | ||
const wrapper = shallow( | ||
<GetTeamInviteLinkModal | ||
config={{EnableUserCreation: 'true'}} | ||
currentTeam={{invite_id: 'invite_id'}} | ||
/> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
test('should match snapshot when user creation is disabled', () => { | ||
const wrapper = shallow( | ||
<GetTeamInviteLinkModal | ||
config={{EnableUserCreation: 'false'}} | ||
currentTeam={{invite_id: 'invite_id'}} | ||
/> | ||
); | ||
|
||
expect(wrapper).toMatchSnapshot(); | ||
}); | ||
|
||
test('should call handleToggle on GetLinkModal\'s onHide', () => { | ||
const wrapper = shallow( | ||
<GetTeamInviteLinkModal | ||
config={{EnableUserCreation: 'false'}} | ||
currentTeam={{invite_id: 'invite_id'}} | ||
/> | ||
); | ||
|
||
wrapper.find(GetLinkModal).first().props().onHide(); | ||
expect(wrapper.state('show')).toBe(false); | ||
}); | ||
}); |