Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions flow-server/src/test/java/com/vaadin/flow/component/TextTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@

import org.junit.jupiter.api.Test;

import com.vaadin.flow.internal.nodefeature.SignalBindingFeature;
import com.vaadin.flow.signals.local.ValueSignal;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

class TextTest {

@Test
void elementAttached() {

Check failure on line 31 in flow-server/src/test/java/com/vaadin/flow/component/TextTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Add at least one assertion to this test case.

See more on https://sonarcloud.io/project/issues?id=vaadin_flow&issues=AZy4YmiDXxz-Zkl7jjrK&open=AZy4YmiDXxz-Zkl7jjrK&pullRequest=23744
// This will throw an assertion error if the element is not attached to
// the component
new Text("Foo").getParent();
Expand Down Expand Up @@ -165,4 +169,20 @@
assertTrue(ex.getMessage()
.contains("because it doesn't represent an HTML Element"));
}

@Test
public void lazyInitSignalBindingFeature() {

Check warning on line 174 in flow-server/src/test/java/com/vaadin/flow/component/TextTest.java

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Remove this 'public' modifier.

See more on https://sonarcloud.io/project/issues?id=vaadin_flow&issues=AZzCG0-9UVJKAWNuOUwy&open=AZzCG0-9UVJKAWNuOUwy&pullRequest=23744
Text text = new Text("text");
text.getElement().getNode()
.getFeatureIfInitialized(SignalBindingFeature.class)
.ifPresent(feature -> fail(
"SignalBindingFeature should not be initialized before binding a signal"));

text.bindText(new ValueSignal<>("text"));

text.getElement().getNode()
.getFeatureIfInitialized(SignalBindingFeature.class)
.orElseThrow(() -> new AssertionError(
"SignalBindingFeature should be initialized after binding a signal"));
}
}
Loading