Skip to content
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ protected String getConstraintMessage(ConstraintType type) {
putConstraintMessage(ConstraintType.FORMAT, msgs.getFormatConstraintMessage());
}

if (type.equals(Type.NUMBER)) {
if (type.equals(Type.NUMBER) || type.equals(Type.INTEGER)) {
putConstraintMessage(ConstraintType.MINIMUM, msgs.getMinimumConstraintMessage());
putConstraintMessage(ConstraintType.MAXIMUM, msgs.getMaximumConstraintMessage());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,7 @@
import io.wcm.testing.mock.aem.junit5.AemContext;
import io.wcm.testing.mock.aem.junit5.AemContextExtension;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.*;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;

Expand All @@ -51,6 +48,7 @@ public class NumberInputImplTest {
private static final String BASE = "/form/numberinput";
private static final String CONTENT_ROOT = "/content";
private static final String PATH_NUMBER_INPUT_CUSTOMIZED = CONTENT_ROOT + "/numberinput-customized";
private static final String PATH_NUMBER_INPUT_INTEGER_TYPE = CONTENT_ROOT + "/numberinput-integer-type";
private static final String PATH_NUMBER_INPUT_CONSTRAINTS = CONTENT_ROOT + "/numberinput-exclusive";
private static final String PATH_NUMBER_INPUT_BACKWARD_COMPATIBLE = CONTENT_ROOT + "/numberinput-backwardcompatible";
private static final String PATH_NUMBER_INPUT_BACKWARD_COMPATIBLE_STRING = CONTENT_ROOT + "/numberinput-backwardcompatible-string";
Expand Down Expand Up @@ -241,6 +239,14 @@ void testGetConstraintMessages() {
assertEquals(Collections.emptyMap(), numberInputMock.getConstraintMessages());
}

@Test
void testGetConstraintMessagesTypeInteger() {
NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT_INTEGER_TYPE, NumberInput.class, context);
Map<ConstraintType, String> constraintsMessages = numberInput.getConstraintMessages();
assertEquals(constraintsMessages.get(ConstraintType.MAXIMUM), "Please enter a valid Number");
assertEquals(constraintsMessages.get(ConstraintType.MINIMUM), "Please enter a valid Number");
}

@Test
void testJSONExportForCustomized() throws Exception {
NumberInput numberInput = Utils.getComponentUnderTest(PATH_NUMBER_INPUT_CUSTOMIZED, NumberInput.class, context);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,30 @@
"minimum" : 10002,
"maximum" : 2000002
},
"numberinput-integer-type" : {
"jcr:primaryType": "nt:unstructured",
"sling:resourceType" : "core/fd/components/form/numberinput/v1/numberinput",
"name" : "abc",
"jcr:title" : "def",
"hideTitle" : true,
"description" : "dummy",
"visible" : false,
"readOnly": false,
"enabled": true,
"assistPriority" : "custom",
"dataRef" : "a.b",
"custom" : "Custom screen reader text",
"typeMessage" : "incorrect type",
"tooltip": "test-short-description",
"fieldType": "number-input",
"type" : "integer",
"maximumMessage" : "Please enter a valid Number",
"minimumMessage" : "Please enter a valid Number",
"exclusiveMinimum" : true,
"exclusiveMaximum" : true,
"minimum" : 10002,
"maximum" : 2000002
},
"numberinput-datalayer": {
"id": "numberinput-57e5de6073",
"sling:resourceType": "core/fd/components/form/numberinput/v1/numberinput",
Expand Down Expand Up @@ -130,4 +154,4 @@
},
":type": "forms-components-examples/components/form/numberinput"
}
}
}