Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added tests for capturing createdAt values and list function behavior #273

Merged
merged 8 commits into from
Feb 21, 2024
15 changes: 13 additions & 2 deletions example/src/LaunchScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,17 +83,28 @@ export default function LaunchScreen(
<View key="run-tests" style={{ margin: 16 }}>
<Button
title="Run All Unit Tests"
onPress={() => navigation.navigate('test', { onlyGroups: false })}
onPress={() => navigation.navigate('test', { testSelection: 'all' })}
accessibilityLabel="Unit-tests"
/>
</View>
<View key="run-group-tests" style={{ margin: 16 }}>
<Button
title="Run Group Unit Tests"
onPress={() => navigation.navigate('test', { onlyGroups: true })}
onPress={() =>
navigation.navigate('test', { testSelection: 'groups' })
}
accessibilityLabel="Unit-group-tests"
/>
</View>
<View key="run-created-at-tests" style={{ margin: 16 }}>
<Button
title="Run Created At Unit Tests"
onPress={() =>
navigation.navigate('test', { testSelection: 'createdAt' })
}
accessibilityLabel="Unit-created-at-tests"
/>
</View>
<View style={styles.divider} />
<Text style={styles.title}>Test Conversations</Text>
<View style={styles.row}>
Expand Down
2 changes: 1 addition & 1 deletion example/src/Navigation.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { createNativeStackNavigator } from '@react-navigation/native-stack'

export type NavigationParamList = {
launch: undefined
test: { onlyGroups?: boolean }
test: { testSelection?: 'groups' | 'createdAt' | 'all' }
home: undefined
group: { id: string }
conversation: { topic: string }
Expand Down
24 changes: 20 additions & 4 deletions example/src/TestScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { useRoute } from '@react-navigation/native'
import React, { useEffect, useState } from 'react'
import { View, Text, Button, ScrollView } from 'react-native'

import { createdAtTests } from './tests/createdAtTests'
import { groupTests } from './tests/groupTests'
import { tests, Test } from './tests/tests'

Expand Down Expand Up @@ -100,16 +101,31 @@ function TestView({
export default function TestScreen(): JSX.Element {
const [completedTests, setCompletedTests] = useState<number>(0)
const route = useRoute()
const params = route.params as { onlyGroups: boolean }
const allTests = tests.concat(groupTests)
const activeTests = params.onlyGroups ? groupTests : allTests
const params = route.params as {
testSelection: 'groups' | 'createdAt' | 'all'
}
const allTests = tests.concat(groupTests).concat(createdAtTests)
let activeTests, title
switch (params.testSelection) {
case 'groups':
activeTests = groupTests
title = 'Group Unit Tests'
break
case 'createdAt':
activeTests = createdAtTests
title = 'Created At Unit Tests'
break
default:
activeTests = allTests
title = 'All Unit Tests'
}

return (
<ScrollView>
<View>
<View style={{ padding: 12 }}>
<Text testID="Test View" accessible accessibilityLabel="Test View">
{params.onlyGroups ? 'Group Unit Tests' : 'All Unit Tests'}
{title}
</Text>
<View
style={{ flexDirection: 'row', justifyContent: 'space-between' }}
Expand Down
Loading
Loading