Client side query validation (#335)

* validate query text

* Update structure of submitted SaveQueryForm data

* form calls correct prop function when invalid query text

* Lowercase directory names
This commit is contained in:
Mike Stone
2016-10-21 17:58:13 -04:00
committed by GitHub
parent 10c32bc47f
commit aa275751b2
22 changed files with 214 additions and 89 deletions
@@ -81,7 +81,7 @@ class SaveQueryForm extends Component {
const { validate } = this;
if (validate(runType)) {
return onSubmit({ formData, runType });
return onSubmit({ ...formData, runType });
}
return false;
@@ -55,16 +55,14 @@ describe('SaveQueryForm - component', () => {
form.simulate('submit');
expect(onSubmit).toHaveBeenCalledWith({
description: null,
duration: 'short',
hosts: 'all',
hostsPercentage: null,
name: queryName,
platforms: 'all',
runType: 'RUN_AND_SAVE',
formData: {
description: null,
duration: 'short',
hosts: 'all',
hostsPercentage: null,
name: queryName,
platforms: 'all',
scanInterval: 0,
},
scanInterval: 0,
});
});
@@ -77,16 +75,14 @@ describe('SaveQueryForm - component', () => {
form.simulate('submit');
expect(onSubmit).toHaveBeenCalledWith({
description: null,
duration: 'short',
hosts: 'all',
hostsPercentage: null,
name: null,
platforms: 'all',
runType: 'RUN',
formData: {
description: null,
duration: 'short',
hosts: 'all',
hostsPercentage: null,
name: null,
platforms: 'all',
scanInterval: 0,
},
scanInterval: 0,
});
});
});