File tree Expand file tree Collapse file tree 3 files changed +35
-7
lines changed
Expand file tree Collapse file tree 3 files changed +35
-7
lines changed Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2017, Globo.com (https://github.com/globocom)
3+ *
4+ * License: MIT
5+ */
6+
7+ /* eslint-env jest */
8+
9+ import getItemType from '../../../src/helpers/getItemType' ;
10+
11+ it ( 'returns empty string if object doesnt have style attribute' , ( ) => {
12+ const mock = { } ;
13+ const result = getItemType ( mock ) ;
14+ expect ( result ) . toEqual ( '' ) ;
15+ } ) ;
Original file line number Diff line number Diff line change 1+ /*
2+ * Copyright (c) 2017, Globo.com (https://github.com/globocom)
3+ *
4+ * License: MIT
5+ */
6+
7+ // @flow
8+
9+ const getItemType = ( item : Object ) : string => {
10+ if ( item . style ) {
11+ if ( Array . isArray ( item . style ) ) {
12+ return item . style . map ( ( i : string ) : string => i . toLowerCase ( ) ) ;
13+ }
14+ return item . style . toLowerCase ( ) ;
15+ }
16+ return '' ;
17+ } ;
18+
19+ export default getItemType ;
Original file line number Diff line number Diff line change @@ -15,13 +15,7 @@ import {
1515import TextStyled from './components/TextStyled' ;
1616import generateKey from './utils/generateKey' ;
1717import flatAttributesList from './flatAttributesList' ;
18-
19- const getItemType = ( item : Object ) : string => {
20- if ( Array . isArray ( item . style ) ) {
21- return item . style . map ( ( i : string ) : string => i . toLowerCase ( ) ) ;
22- }
23- return item . style . toLowerCase ( ) ;
24- } ;
18+ import getItemType from './helpers/getItemType' ;
2519
2620const getItemOnPress = ( item : Object , entityMap : Object , navigate : Function ) => {
2721 if ( item . key !== undefined ) {
You can’t perform that action at this time.
0 commit comments