1import React from 'react'; 2import { View, Text, Pressable } from 'react-native'; 3 4import * as Updates from '../'; 5 6const { checkForUpdateAsync, fetchUpdateAsync, useUpdates } = Updates; 7 8const UseUpdatesTestApp = () => { 9 const { 10 currentlyRunning, 11 availableUpdate, 12 downloadedUpdate, 13 isUpdateAvailable, 14 isUpdatePending, 15 checkError, 16 downloadError, 17 lastCheckForUpdateTimeSinceRestart, 18 } = useUpdates(); 19 return ( 20 <View> 21 {/* Currently running info */} 22 <Text testID="currentlyRunning_updateId">{currentlyRunning.updateId}</Text> 23 <Text testID="currentlyRunning_channel">{currentlyRunning.channel}</Text> 24 <Text testID="currentlyRunning_createdAt"> 25 {currentlyRunning?.createdAt ? currentlyRunning?.createdAt.toISOString() : ''} 26 </Text> 27 {/* Last time there was a check for update */} 28 <Text testID="lastCheckForUpdateTime"> 29 {lastCheckForUpdateTimeSinceRestart?.toISOString().substring(0, 19) || ''} 30 </Text> 31 {/* Available update, if one is present */} 32 <Text testID="availableUpdate_updateId">{availableUpdate?.updateId || ''}</Text> 33 {/* Downloaded update, if one is present */} 34 <Text testID="downloadedUpdate_updateId">{downloadedUpdate?.updateId || ''}</Text> 35 {/* Booleans */} 36 <Text testID="isUpdateAvailable">{`${isUpdateAvailable}`}</Text> 37 <Text testID="isUpdatePending">{`${isUpdatePending}`}</Text> 38 {/* Error, if one has occurred */} 39 {checkError ? <Text testID="checkError">{checkError.message}</Text> : null} 40 {downloadError ? <Text testID="downloadError">{downloadError.message}</Text> : null} 41 {/* Buttons for test code to invoke methods */} 42 <Pressable testID="checkForUpdate" onPress={() => checkForUpdateAsync()} /> 43 <Pressable testID="downloadUpdate" onPress={() => fetchUpdateAsync()} /> 44 </View> 45 ); 46}; 47 48export default UseUpdatesTestApp; 49