Merge pull request #98 from pi-hole/fix/domain-input-empty

Don't handle empty input in DomainInput
This commit is contained in:
Mark Drobnak
2018-10-26 01:42:37 -04:00
committed by GitHub
2 changed files with 9 additions and 3 deletions
+6
View File
@@ -25,6 +25,12 @@ class DomainInput extends Component {
e.preventDefault();
const domain = this.state.domain;
// Don't do anything for empty inputs
if (domain.length === 0) {
return;
}
const isValid = this.props.isValid(domain);
this.setState({ isValid });
if (isValid) {
+3 -3
View File
@@ -128,15 +128,15 @@ it("does not call onEnter when input is empty", () => {
<DomainInput
onEnter={onEnter}
onRefresh={jest.fn()}
isValid={isValidDomain}
isValid={() => true}
onValidationError={jest.fn()}
/>
);
wrapper
.find("button")
.find("form")
.first()
.simulate("click");
.simulate("submit", { preventDefault: jest.fn() });
expect(onEnter).not.toHaveBeenCalled();
});