Fakultas Ilmu Komputer UI

Commit bb2114b6 authored by Zulia Putri's avatar Zulia Putri 🤤
Browse files

1606918446 223 2

parent 8669470d
......@@ -63,7 +63,9 @@ describe('LoginForm', () => {
<LoginForm url="" />,
);
const submitButton = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Button');
const submitButton = ReactTestUtils.findRenderedDOMComponentWithClass(formLogin, 'submit');
console.log(submitButton);
ReactTestUtils.Simulate.click(submitButton);
const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form');
......@@ -77,7 +79,7 @@ describe('LoginForm', () => {
<LoginForm url="" />,
);
const submitButton = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Button');
const submitButton = ReactTestUtils.findRenderedDOMComponentWithClass(formLogin, 'submit');
ReactTestUtils.Simulate.click(submitButton);
const form = ReactTestUtils.findRenderedDOMComponentWithTag(formLogin, 'Form');
......
......@@ -33,17 +33,25 @@ export default class LoginForm extends React.Component {
this.state = {
username: '',
password: '',
hide: true,
errorFlag: false,
loading: false,
};
this.handleChange = this.handleChange.bind(this);
this.handleSubmit = this.handleSubmit.bind(this);
this.handleClick = this.handleClick.bind(this);
}
handleChange(event, name) {
this.setState({ [name]: event.target.value });
}
handleClick(event) {
event.preventDefault();
this.setState({ hide: !this.state.hide });
}
handleSubmit(event) {
event.preventDefault();
const data = {
......@@ -103,17 +111,22 @@ export default class LoginForm extends React.Component {
<Form.Field>
<label htmlFor="password"> Password </label>
<Input
type="password"
type={this.state.hide ? "password" : "text"}
id="password"
icon="key"
iconPosition="left"
action={{
icon: this.state.hide ? "unhide" : "hide",
onClick: this.handleClick
}}
placeholder="password"
value={this.state.password}
onChange={(e) => this.handleChange(e, 'password')}
required
/>
</Form.Field>
</Form.Group>
<Button type="submit" fluid color="blue">
<Button className="submit" type="submit" fluid color="blue">
Login
</Button>
<Message
......
This diff is collapsed.
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment