Add component tests

This commit is contained in:
Christoph Atteneder 2018-02-19 10:08:53 +01:00
parent 59123f83e6
commit a02f586a7e
No known key found for this signature in database
GPG key ID: CD5DC1C529CDFD3B

View file

@ -1,5 +1,37 @@
package io.bisq.gui.components; package io.bisq.gui.components;
import javafx.scene.text.Text;
import org.junit.Test;
import static org.junit.Assert.assertEquals;
public class ColoredDecimalPlacesWithZerosTextTest { public class ColoredDecimalPlacesWithZerosTextTest {
@Test
public void testOnlyZeroDecimals() {
ColoredDecimalPlacesWithZerosText text = new ColoredDecimalPlacesWithZerosText("1.0000");
Text beforeZeros = (Text) text.getChildren().get(0);
Text zeroDecimals = (Text) text.getChildren().get(1);
assertEquals("1.0", beforeZeros.getText());
assertEquals("000", zeroDecimals.getText());
}
@Test
public void testOneZeroDecimal() {
ColoredDecimalPlacesWithZerosText text = new ColoredDecimalPlacesWithZerosText("1.2570");
Text beforeZeros = (Text) text.getChildren().get(0);
Text zeroDecimals = (Text) text.getChildren().get(1);
assertEquals("1.257", beforeZeros.getText());
assertEquals("0", zeroDecimals.getText());
}
@Test
public void testMultipleZeroDecimal() {
ColoredDecimalPlacesWithZerosText text = new ColoredDecimalPlacesWithZerosText("1.2000");
Text beforeZeros = (Text) text.getChildren().get(0);
Text zeroDecimals = (Text) text.getChildren().get(1);
assertEquals("1.2", beforeZeros.getText());
assertEquals("000", zeroDecimals.getText());
}
} }