-
Notifications
You must be signed in to change notification settings - Fork 66
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: restructure and enhance validation unit tests (#4350)
* test: add basic validation unit tests * remove unused imports * add license headers * Update vaadin-text-field-flow-parent/vaadin-text-field-flow/src/test/java/com/vaadin/flow/component/textfield/validation/AbstractBasicValidationTest.java Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com> * Update vaadin-text-field-flow-parent/vaadin-text-field-flow/src/test/java/com/vaadin/flow/component/textfield/validation/AbstractBasicValidationTest.java Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com> * Update vaadin-text-field-flow-parent/vaadin-text-field-flow/src/test/java/com/vaadin/flow/component/textfield/validation/AbstractBasicValidationTest.java Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com> * Update vaadin-text-field-flow-parent/vaadin-text-field-flow/src/test/java/com/vaadin/flow/component/textfield/validation/AbstractBasicValidationTest.java Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com> Co-authored-by: Sascha Ißbrücker <sissbruecker@vaadin.com>
- Loading branch information
1 parent
fc149fb
commit c913d04
Showing
21 changed files
with
461 additions
and
230 deletions.
There are no files selected for viewing
34 changes: 0 additions & 34 deletions
34
.../src/test/java/com/vaadin/flow/component/textfield/binder/IntegerFieldValidationTest.java
This file was deleted.
Oops, something went wrong.
34 changes: 0 additions & 34 deletions
34
...w/src/test/java/com/vaadin/flow/component/textfield/binder/NumberFieldValidationTest.java
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
...src/test/java/com/vaadin/flow/component/textfield/binder/PasswordFieldValidationTest.java
This file was deleted.
Oops, something went wrong.
36 changes: 0 additions & 36 deletions
36
...flow/src/test/java/com/vaadin/flow/component/textfield/binder/TextAreaValidationTest.java
This file was deleted.
Oops, something went wrong.
35 changes: 0 additions & 35 deletions
35
...low/src/test/java/com/vaadin/flow/component/textfield/binder/TextFieldValidationTest.java
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
...test/java/com/vaadin/flow/component/textfield/validation/AbstractBasicValidationTest.java
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,59 @@ | ||
/* | ||
* Copyright 2000-2022 Vaadin Ltd. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not | ||
* use this file except in compliance with the License. You may obtain a copy of | ||
* the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
* License for the specific language governing permissions and limitations under | ||
* the License. | ||
*/ | ||
package com.vaadin.flow.component.textfield.validation; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
|
||
import com.vaadin.flow.component.Component; | ||
import com.vaadin.flow.component.HasValidation; | ||
|
||
public abstract class AbstractBasicValidationTest<T extends Component & HasValidation> { | ||
protected T testField; | ||
|
||
@Before | ||
public void setup() { | ||
testField = createTestField(); | ||
} | ||
|
||
@Test | ||
public void setErrorMessage_getErrorMessage() { | ||
Assert.assertNull(testField.getErrorMessage()); | ||
Assert.assertNull(testField.getElement().getProperty("errorMessage")); | ||
|
||
testField.setErrorMessage("Error"); | ||
|
||
Assert.assertEquals("Error", testField.getErrorMessage()); | ||
Assert.assertEquals("Error", | ||
testField.getElement().getProperty("errorMessage")); | ||
} | ||
|
||
@Test | ||
public void setInvalid_isInvalid() { | ||
Assert.assertFalse(testField.isInvalid()); | ||
Assert.assertEquals("false", | ||
testField.getElement().getProperty("invalid")); | ||
|
||
testField.setInvalid(true); | ||
|
||
Assert.assertTrue(testField.isInvalid()); | ||
Assert.assertEquals("true", | ||
testField.getElement().getProperty("invalid")); | ||
} | ||
|
||
abstract protected T createTestField(); | ||
} |
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
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
21 changes: 18 additions & 3 deletions
21
...binder/BigDecimalFieldValidationTest.java → .../BigDecimalFieldBinderValidationTest.java
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
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
21 changes: 18 additions & 3 deletions
21
...ield/binder/EmailFieldValidationTest.java → ...ation/EmailFieldBinderValidationTest.java
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
Oops, something went wrong.