import { Platform } from 'react-native';
import _ from 'lodash';

const getPlatformTestId = (id, prefix = '') => {
	const testID = (_.isEmpty(id)) ? '' : id;
	return (
		Platform.OS === 'ios' ? { testID } : { accessible: true, accessibilityLabel: `${prefix}${testID}` }
	);
};

/**
  * Adds a testID to the views on Android and iOS in their specific ways. On Android,
  * this will result in a ContentDescription on Debug builds (and no changes on live builds).
  */
const setTestID = (id, prefix) => getPlatformTestId(id, prefix);

export default setTestID;
