Skip to content

Commit

Permalink
Only check MediaPlaceholder allowedTypes array length if prop exists (#…
Browse files Browse the repository at this point in the history
…11694)

* Only check MediaPlaceholder allowedTypes array length if allowedTypes prop exists

Fixes #11692

Adds basic unit test to demonstrate the bug described in #11692.

* Initialize allowedTypes to [] instead of modifying conditional

* Reinstate array length check
  • Loading branch information
kadamwhite authored and youknowriad committed Nov 13, 2018
1 parent 3ff9890 commit eb4ed63
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/editor/src/components/media-placeholder/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ class MediaPlaceholder extends Component {
onHTMLDrop = noop,
multiple = false,
notices,
allowedTypes,
allowedTypes = [],
} = this.props;

const {
Expand Down
17 changes: 17 additions & 0 deletions packages/editor/src/components/media-placeholder/test/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* External dependencies
*/
import { mount } from 'enzyme';

/**
* Internal dependencies
*/
import MediaPlaceholder from '../';

describe( 'MediaPlaceholder', () => {
it( 'renders successfully when allowedTypes property is not specified', () => {
expect( () => mount(
<MediaPlaceholder />
) ).not.toThrow();
} );
} );

0 comments on commit eb4ed63

Please sign in to comment.