-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Improve user form for new users usage
- Loading branch information
1 parent
c230409
commit 9f0b05e
Showing
3 changed files
with
79 additions
and
48 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,22 @@ | ||
import React from "react" | ||
import classes from './NewUser.sass' | ||
import {connect} from "react-redux"; | ||
import {createStructuredSelector} from "reselect"; | ||
import UserForm from "../UserForm/UserForm"; | ||
import UserSettingsApi from "../../api/userSettingsApi"; | ||
|
||
const NewUser = ({user}) => { | ||
const saveUser = () => { | ||
UserSettingsApi.updateUser(userSettingsParam); | ||
const NewUser = () => { | ||
const saveUser = (userData) => { | ||
// TODO: needs a create user | ||
UserSettingsApi.updateUser(userData); | ||
} | ||
|
||
return ( | ||
<div className={classes.NewUser}> | ||
<UserForm | ||
user={user} | ||
title='Criar novo usuário' | ||
saveUser={saveUser} | ||
/> | ||
</div> | ||
); | ||
}; | ||
|
||
|
||
const mapStateToProps = createStructuredSelector({ | ||
user: state => state.app.user | ||
}); | ||
|
||
export default connect(mapStateToProps, null)(NewUser); | ||
export default NewUser; |
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 React from 'react'; | ||
|
||
import { configure, mount } from 'enzyme'; | ||
import Adapter from 'enzyme-adapter-react-16'; | ||
import NewUser from "./NewUser"; | ||
|
||
configure({adapter: new Adapter()}); | ||
|
||
describe('<NewUser />', () => { | ||
it('renders <NewUser /> components', () => { | ||
const wrapper = mount(<NewUser />); | ||
expect(wrapper.find('input')).toHaveLength(5); | ||
expect(wrapper.find('h1').text()).toEqual('Criar novo usuário'); | ||
}); | ||
|
||
describe('when click on save button', () => { | ||
it('shows error message', () => { | ||
const wrapper = mount(<NewUser />); | ||
wrapper.find('button').simulate('click'); | ||
expect(wrapper.find('TextInputWithLabel').get(0).props.error).toEqual('Este campo é obrigatório') | ||
expect(wrapper.find('TextInputWithLabel').get(1).props.error).toEqual('Este campo é obrigatório') | ||
expect(wrapper.find('TextInputWithLabel').get(2).props.error).toEqual('Este campo é obrigatório') | ||
expect(wrapper.find('TextInputWithLabel').get(3).props.error).toEqual('Este campo é obrigatório') | ||
expect(wrapper.find('TextInputWithLabel').get(4).props.error).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