Skip to content

Commit

Permalink
Element: Update logic for getWrapperDisplayName method
Browse files Browse the repository at this point in the history
  • Loading branch information
gziolo committed Dec 6, 2017
1 parent e11cba0 commit 26f0e59
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
4 changes: 2 additions & 2 deletions element/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import { createElement, Component, cloneElement, Children } from 'react';
import { render, findDOMNode, createPortal, unmountComponentAtNode } from 'react-dom';
import { renderToStaticMarkup } from 'react-dom/server';
import { flowRight, isString, startCase } from 'lodash';
import { camelCase, flowRight, isString, upperFirst } from 'lodash';

/**
* Returns a new element of given type. Type can be either a string tag name or
Expand Down Expand Up @@ -135,5 +135,5 @@ export { flowRight as compose };
export function getWrapperDisplayName( BaseComponent, wrapperName ) {
const { displayName = BaseComponent.name || 'Component' } = BaseComponent;

return `${ startCase( wrapperName ) }(${ displayName })`;
return `${ upperFirst( camelCase( wrapperName ) ) }(${ displayName })`;
}
4 changes: 4 additions & 0 deletions element/test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,10 @@ describe( 'element', () => {
expect( getWrapperDisplayName( () => <div />, 'test' ) ).toBe( 'Test(Component)' );
} );

it( 'should use camel case starting with upper for wrapper prefix ', () => {
expect( getWrapperDisplayName( () => <div />, 'one-two_threeFOUR' ) ).toBe( 'OneTwoThreeFour(Component)' );
} );

it( 'should use function name', () => {
function SomeComponent() {
return <div />;
Expand Down

0 comments on commit 26f0e59

Please sign in to comment.