Skip to content

Commit

Permalink
Add form fixture
Browse files Browse the repository at this point in the history
  • Loading branch information
philipp-spiess committed Aug 9, 2018
1 parent 249f408 commit c7d8ad3
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
55 changes: 55 additions & 0 deletions fixtures/dom/src/components/fixtures/event-pooling/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import TestCase from '../../TestCase';

const React = window.React;

class Form extends React.Component {
state = {
submits: 0,
resets: 0,
};

handleSubmit = event => {
event.preventDefault();
this.setState(state => ({submits: state.submits + 1}));
};

handleReset = event => {
event.preventDefault();
this.setState(state => ({resets: state.resets + 1}));
};

render() {
const {submits, resets} = this.state;

const formStyle = {
padding: '10px 20px',
border: '1px solid #d9d9d9',
margin: '10px 0 20px',
};

return (
<TestCase title="Form" description="">
<TestCase.Steps>
<li>Click Submit</li>
<li>Click Reset</li>
</TestCase.Steps>

<TestCase.ExpectedResult>
The event count should increase by one for every click.
</TestCase.ExpectedResult>

<form style={formStyle} onSubmit={this.handleSubmit}>
<p>onSubmit calls: {submits}</p>
<input type="submit" />
</form>

<form style={formStyle} onReset={this.handleReset}>
<p>onReset calls: {resets}</p>
<input type="reset" />
</form>
</TestCase>
);
}
}

export default Form;
2 changes: 2 additions & 0 deletions fixtures/dom/src/components/fixtures/event-pooling/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import FixtureSet from '../../FixtureSet';
import MouseMove from './mouse-move';
import Persistence from './persistence';
import Form from './form';

const React = window.React;

Expand All @@ -10,6 +11,7 @@ class EventPooling extends React.Component {
<FixtureSet title="Event Pooling" description="">
<MouseMove />
<Persistence />
<Form />
</FixtureSet>
);
}
Expand Down

0 comments on commit c7d8ad3

Please sign in to comment.