diff --git a/clients/tests/unit/render/Fields/FileInput.test.js b/clients/tests/unit/render/Fields/FileInput.test.js index 36781a81a..c68840de6 100644 --- a/clients/tests/unit/render/Fields/FileInput.test.js +++ b/clients/tests/unit/render/Fields/FileInput.test.js @@ -36,9 +36,9 @@ describe('File Field ', () => { }); - it.skip('Prepares props from field config that is required', () => { + it('Prepares props from field config that is required', () => { const prepared = FileInput.fieldConfigToProps(fileFieldConfigs.required_multiple_has_button_text); - expect(prepared.multiple).toEqual('true'); + expect(prepared.multiple).toEqual(true); expect(prepared.field.hasOwnProperty('required')).toEqual(true); }); @@ -68,14 +68,20 @@ describe('File Field ', () => { expect(prepared.multiUploadText).toEqual('The Custom Text'); }); - it.skip('Prepares props and sets the allowed types in inputProps when it should', () => { - const prepared = FileInput.fieldConfigToProps(fileFieldConfigs.required_single); - //expect( fileFieldConfigs ).toEqual( 'image/png'); + it('Prepares props and sets the allowed types in inputProps when it should', () => { + const prepared = FileInput.fieldConfigToProps(fileFieldConfigs.required_single_allow_png); expect(prepared.accept).toEqual('image/png'); expect(prepared.inputProps).toEqual({"accept": "image/png", "type": "file"} ); }); + it( 'Sets field.isRequired to false if not passed', () => { + let field = fileFieldConfigs.required_multiple_no_button_text; + delete field.isRequired; + const prepared = FileInput.fieldConfigToProps(field); + expect(prepared.isRequired).toEqual(true); + }); + Object.keys(fileFieldConfigs).forEach(fieldId => { it(`Matches snapshot for ${fieldId}`, () => { const field = fileFieldConfigs[fieldId]; diff --git a/clients/tests/unit/render/Fields/Mocks/fileFieldConfigs.js b/clients/tests/unit/render/Fields/Mocks/fileFieldConfigs.js index 91c5e6726..8de577519 100644 --- a/clients/tests/unit/render/Fields/Mocks/fileFieldConfigs.js +++ b/clients/tests/unit/render/Fields/Mocks/fileFieldConfigs.js @@ -1,4 +1,4 @@ -export const fileFieldConfigs = { +export const fileFieldConfigs = { required_single: { type: 'file', @@ -16,12 +16,12 @@ export const fileFieldConfigs = { multiple: 'false', multiUploadText: 'My multi Upload Text', allowedTypes: 'false', - usePreviews: 'false', + usePreviews: 'false', previewHeight: 24, previewWidth: 24, } }, - required_single_allow_png: + required_single_allow_png: { type: 'file', outterIdAttr: 'required_single_allow_png', @@ -32,7 +32,7 @@ export const fileFieldConfigs = { required: true, isRequired: { required: true - }, + }, fieldDefault: '', fieldValue: [], fieldIdAttr: 'required_single', @@ -40,10 +40,10 @@ export const fileFieldConfigs = { { multiple: 'false', multiUploadText: 'Cool text for required_single_allow_png', - allowedTypes: '.png', - usePreviews: true, - previewHeight: 24, - previewWidth: 24, + allowedTypes: 'image/png', + usePreviews: true, + previewHeight: 24, + previewWidth: 24, } }, required_multiple_no_button_text: @@ -63,7 +63,7 @@ export const fileFieldConfigs = { multiple: 1, multiUploadText: false, allowedTypes: 'false', - usePreviews: true, + usePreviews: true, previewHeight: 24, previewWidth: 24, } @@ -107,7 +107,7 @@ export const fileFieldConfigs = { multiple: 'false', multiUploadText: false, allowedTypes: 'false', - usePreviews: true, + usePreviews: true, previewHeight: 24, previewWidth: 24, } @@ -129,7 +129,7 @@ export const fileFieldConfigs = { multiple: 1, multiUploadText: false, allowedTypes: 'false', - usePreviews: true, + usePreviews: true, previewHeight: 24, previewWidth: 24, } @@ -151,7 +151,7 @@ export const fileFieldConfigs = { multiple: 1, multiUploadText: 'The Default Text', allowedTypes: 'false', - usePreviews: true, + usePreviews: true, previewHeight: 24, previewWidth: 24, } @@ -173,7 +173,7 @@ export const fileFieldConfigs = { multiple: 1, multiUploadText: 'The Default Text', allowedTypes: 'false', - usePreviews: true, + usePreviews: true, previewHeight: 20, previewWidth: 40, }