Skip to content

Commit

Permalink
lint fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
cameronvoell committed Feb 28, 2024
1 parent 39f8737 commit 6475360
Show file tree
Hide file tree
Showing 5 changed files with 41 additions and 34 deletions.
24 changes: 14 additions & 10 deletions example/src/LaunchScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import * as XMTP from 'xmtp-react-native-sdk'
import { useXmtp } from 'xmtp-react-native-sdk'

import { NavigationParamList } from './Navigation'
import { TestCategory } from './TestScreen'
import { supportedCodecs } from './contentTypes/contentTypes'
import { useSavedKeys } from './hooks'
import { TestCategory } from './TestScreen'

const appVersion = 'XMTP_RN_EX/0.0.1'

Expand All @@ -18,7 +18,9 @@ export default function LaunchScreen(
this: any,
{ navigation }: NativeStackScreenProps<NavigationParamList, 'launch'>
) {
const [selectedTest, setSelectedTest] = useState<TestCategory>(TestCategory.all)
const [selectedTest, setSelectedTest] = useState<TestCategory>(
TestCategory.all
)
const [selectedNetwork, setSelectedNetwork] = useState<
'dev' | 'local' | 'production'
>('dev')
Expand Down Expand Up @@ -67,10 +69,12 @@ export default function LaunchScreen(
{ key: 1, label: 'false' },
]

const testOptions = Object.entries(TestCategory).map(([key, value], index) => ({
key: index,
label: value
}));
const testOptions = Object.entries(TestCategory).map(
([key, value], index) => ({
key: index,
label: value,
})
)

useEffect(() => {
;(async () => {
Expand All @@ -96,15 +100,15 @@ export default function LaunchScreen(
selectTextStyle={styles.modalSelectText}
backdropPressToClose
initValue={selectedTest}
onChange={(option) =>
setSelectedTest(option.label as TestCategory)
}
onChange={(option) => setSelectedTest(option.label as TestCategory)}
/>
</View>
<View key="run-tests" style={{ margin: 16 }}>
<Button
title={`Run Selected Tests: ${selectedTest}`}
onPress={() => navigation.navigate('test', { testSelection: selectedTest })}
onPress={() =>
navigation.navigate('test', { testSelection: selectedTest })
}
accessibilityLabel="Unit-tests"
/>
</View>
Expand Down
2 changes: 1 addition & 1 deletion example/src/Navigation.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { createNativeStackNavigator } from '@react-navigation/native-stack'

Check warning on line 1 in example/src/Navigation.tsx

View workflow job for this annotation

GitHub Actions / lint

There should be at least one empty line between import groups
import { TestCategory } from './tests/test-utils'
import { TestCategory } from './TestScreen'

export type NavigationParamList = {
launch: undefined
Expand Down
3 changes: 1 addition & 2 deletions example/src/TestScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import { View, Text, Button, ScrollView } from 'react-native'

import { createdAtTests } from './tests/createdAtTests'
import { groupTests } from './tests/groupTests'
import { tests } from './tests/tests'
import { Test } from './tests/test-utils'
import { tests } from './tests/tests'

type Result = 'waiting' | 'running' | 'success' | 'failure' | 'error'

Expand Down Expand Up @@ -106,7 +106,6 @@ export enum TestCategory {
createdAt = 'createdAt',
}


export default function TestScreen(): JSX.Element {
const [completedTests, setCompletedTests] = useState<number>(0)
const route = useRoute()
Expand Down
44 changes: 24 additions & 20 deletions example/src/tests/test-utils.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,37 @@
import { Platform } from "expo-modules-core";
import { Client } from "xmtp-react-native-sdk";
import { Platform } from 'expo-modules-core'
import { Client } from 'xmtp-react-native-sdk'

export type Test = {
name: string
run: () => Promise<boolean>
name: string
run: () => Promise<boolean>
}

export function isIos() {
return Platform.OS === 'ios'
return Platform.OS === 'ios'
}

export async function delayToPropogate(milliseconds = 100): Promise<void> {
// delay avoid clobbering
return new Promise((r) => setTimeout(r, milliseconds))
// delay avoid clobbering
return new Promise((r) => setTimeout(r, milliseconds))
}

export function assert(condition: boolean, msg: string) {
if (!condition) {
throw new Error(msg)
}
if (!condition) {
throw new Error(msg)
}
}

export async function createClients(numClients: number): Promise<Client<any>[]> {
const clients = [];
for (let i = 0; i < numClients; i++) {
clients.push(await Client.createRandom({
env: 'local',
enableAlphaMls: true,
}));
}
return clients;
}
export async function createClients(
numClients: number
): Promise<Client<any>[]> {
const clients = []
for (let i = 0; i < numClients; i++) {
clients.push(
await Client.createRandom({
env: 'local',
enableAlphaMls: true,
})
)
}
return clients
}
2 changes: 1 addition & 1 deletion example/src/tests/tests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import ReactNativeBlobUtil from 'react-native-blob-util'
import { TextEncoder, TextDecoder } from 'text-encoding'
import { DecodedMessage } from 'xmtp-react-native-sdk/lib/DecodedMessage'

import { Test, assert, delayToPropogate } from './test-utils'
import {
Query,
JSContentCodec,
Expand All @@ -13,7 +14,6 @@ import {
RemoteAttachmentCodec,
RemoteAttachmentContent,
} from '../../../src/index'
import { Test, assert, delayToPropogate } from './test-utils'

type EncodedContent = content.EncodedContent
type ContentTypeId = content.ContentTypeId
Expand Down

0 comments on commit 6475360

Please sign in to comment.