All files / src/__tests__ utils.js

100% Statements 11/11
100% Branches 4/4
100% Functions 4/4
100% Lines 10/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25            29x 25x     2x       26x 26x 26x     2x 5x 5x 5x    
/* eslint react/prop-types: 0 */
 
import React, { createElement } from 'react'
import { Text } from 'react-native'
import * as StackUtils from './../StackUtils'
 
export const componentFactory = message => ({ match }) => (
  <Text>{(match && (match.params.id || match.params.slug)) || message}</Text>
)
 
export const renderCardView = ({
  navigationState: { routes, index },
  cards,
}) => {
  const route = routes[index]
  const card = StackUtils.get(cards, route)
  return createElement(card.render, { key: card.key })
}
 
export const renderTabView = ({ navigationState: { routes, index }, tabs }) => {
  const route = routes[index]
  const tab = StackUtils.get(tabs, route)
  return createElement(tab.render, { key: tab.key })
}