Skip to content

Commit

Permalink
#2766 tests to prove that the file field does not indicate that it is…
Browse files Browse the repository at this point in the history
… required with a * and the right markup
  • Loading branch information
Josh Pollock committed Nov 19, 2018
1 parent d76d57e commit 2b48a85
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions clients/tests/unit/render/Fields/FileInput.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,9 @@ describe('File Field ', () => {
});
});




});


21 changes: 21 additions & 0 deletions clients/tests/unit/render/Fields/Mocks/MockFileRenderer.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down Expand Up @@ -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(
<FileInput
field={field}
multiple={multiple}
multiUploadText={multiUploadText}
onChange={() => {}}
inputProps={inputProps}
/>
);

expect( component.find( '.field_required').length ).toBe( 1 );
expect( component.contains( '*' ) ).toBe( true );

});


});

0 comments on commit 2b48a85

Please sign in to comment.