Skip to content

Commit 49cd2ed

Browse files
test cases fixed for extensions support in file input
1 parent e525b83 commit 49cd2ed

File tree

3 files changed

+19
-4
lines changed

3 files changed

+19
-4
lines changed

bundles/af-core/src/test/java/com/adobe/cq/forms/core/components/internal/models/v3/form/FileInputImplV3Test.java

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717

1818
import java.util.Arrays;
1919
import java.util.Collections;
20+
import java.util.List;
2021
import java.util.Map;
2122

2223
import org.apache.commons.lang3.reflect.FieldUtils;
@@ -41,7 +42,7 @@
4142
import io.wcm.testing.mock.aem.junit5.AemContext;
4243
import io.wcm.testing.mock.aem.junit5.AemContextExtension;
4344

44-
import static org.hamcrest.CoreMatchers.*;
45+
import static org.hamcrest.CoreMatchers.is;
4546
import static org.junit.Assert.assertEquals;
4647
import static org.junit.Assert.assertFalse;
4748
import static org.junit.Assert.assertThat;
@@ -59,7 +60,6 @@ public class FileInputImplV3Test {
5960
private static final String PATH_FILEINPUT_DATALAYER = CONTENT_ROOT + "/fileinput-datalayer";
6061
private static final String PATH_MULTISELECT_FILEINPUT = CONTENT_ROOT + "/multiselect-fileinput";
6162
private static final String PATH_MULTISELECT_FILEINPUT_WITHNOTYPE = CONTENT_ROOT + "/multiselect-fileinput-withNoType";
62-
private static final String PATH_FILEINPUT_WITH_MIME_TYPE = CONTENT_ROOT + "/fileinput-with-mime-type";
6363

6464
private final AemContext context = FormsCoreComponentTestContext.newAemContext();
6565

@@ -404,11 +404,18 @@ void testJSONExportDataLayer() throws Exception {
404404

405405
@Test
406406
void testGetAcceptExtensions() {
407-
FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT_CUSTOMIZED, FileInput.class, context);
407+
FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT_DATALAYER, FileInput.class, context);
408408
// assert fileInput.getAcceptExtensions() to return empty list
409409
assertEquals(Collections.emptyList(), fileInput.getAcceptExtensions());
410410
FileInput fileInputMock = Mockito.mock(FileInput.class);
411411
Mockito.when(fileInputMock.getAcceptExtensions()).thenCallRealMethod();
412412
assertEquals(Collections.emptyList(), fileInput.getAcceptExtensions());
413413
}
414+
415+
@Test
416+
void testGetAcceptExtensionsWithExtensions() {
417+
FileInput fileInput = Utils.getComponentUnderTest(PATH_FILEINPUT_CUSTOMIZED, FileInput.class, context);
418+
List<String> extensions = fileInput.getAcceptExtensions();
419+
assertThat(Arrays.asList(".jpg", ".png"), is(extensions));
420+
}
414421
}

bundles/af-core/src/test/resources/form/fileinputv3/exporter-fileinput-customized.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,10 @@
2121
"video/*",
2222
"image/*"
2323
],
24+
"acceptExtensions": [
25+
"jpg",
26+
"png"
27+
],
2428
"dataRef":"a.b",
2529
"events": {
2630
"custom:setProperty": [

bundles/af-core/src/test/resources/form/fileinputv3/test-content.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@
3131
"custom" : "Custom screen reader text",
3232
"tooltip": "test-short-description",
3333
"maxFileSize" : "4",
34-
"accept" : ["audio/*", "video/*", "image/*"]
34+
"accept" : ["audio/*", "video/*", "image/*"],
35+
"acceptExtensions": [
36+
"jpg",
37+
"png"
38+
]
3539
},
3640
"multiselect-fileinput" : {
3741
"jcr:primaryType": "nt:unstructured",

0 commit comments

Comments
 (0)