From 2b48a850fc9fea604925999b60ab3f563deb4572 Mon Sep 17 00:00:00 2001 From: Josh Pollock Date: Mon, 19 Nov 2018 15:14:56 -0500 Subject: [PATCH] #2766 tests to prove that the file field does not indicate that it is required with a * and the right markup --- .../unit/render/Fields/FileInput.test.js | 3 +++ .../Fields/Mocks/MockFileRenderer.test.js | 21 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/clients/tests/unit/render/Fields/FileInput.test.js b/clients/tests/unit/render/Fields/FileInput.test.js index c68840de6..184fe67ca 100644 --- a/clients/tests/unit/render/Fields/FileInput.test.js +++ b/clients/tests/unit/render/Fields/FileInput.test.js @@ -99,6 +99,9 @@ describe('File Field ', () => { }); }); + + + }); diff --git a/clients/tests/unit/render/Fields/Mocks/MockFileRenderer.test.js b/clients/tests/unit/render/Fields/Mocks/MockFileRenderer.test.js index 1937ce4f5..1ac6904c6 100644 --- a/clients/tests/unit/render/Fields/Mocks/MockFileRenderer.test.js +++ b/clients/tests/unit/render/Fields/Mocks/MockFileRenderer.test.js @@ -4,6 +4,7 @@ import {fileFieldConfigs} from "./fileFieldConfigs"; import {MockFileFieldRenderer} from "./MockFileFieldRenderer"; import React from 'react'; import {FileInput} from '../../../../../render/components/Fields/FileInput' +import renderer from "react-test-renderer"; //https://gist.github.com/josephhanson/372b44f93472f9c5a2d025d40e7bb4cc function MockFile() { @@ -192,5 +193,25 @@ describe('DOM testing file components', () => { expect(component.find('.btn').text()).toEqual("The Custom Text"); }); + it('Shows * inside .field_required span when field is required', () => { + let prepared = FileInput.fieldConfigToProps(fileFieldConfigs.required_single_allow_png); + let field = prepared.field; + const {multiple, multiUploadText, inputProps} = prepared; + + const component = shallow( + {}} + inputProps={inputProps} + /> + ); + + expect( component.find( '.field_required').length ).toBe( 1 ); + expect( component.contains( '*' ) ).toBe( true ); + + }); + });