Pause adding unit tests
This commit is contained in:
parent
e430873771
commit
46dd50adfb
|
@ -27,7 +27,10 @@ export default function SetList() {
|
||||||
const [ids, setIds] = useState<number[]>([])
|
const [ids, setIds] = useState<number[]>([])
|
||||||
const navigation = useNavigation<NavigationProp<HomePageParams>>()
|
const navigation = useNavigation<NavigationProp<HomePageParams>>()
|
||||||
|
|
||||||
|
console.log('Rendered SetList')
|
||||||
|
|
||||||
const refresh = useCallback(async (value: string) => {
|
const refresh = useCallback(async (value: string) => {
|
||||||
|
console.log('Getting sets...')
|
||||||
const newSets = await setRepo.find({
|
const newSets = await setRepo.find({
|
||||||
where: {name: Like(`%${value}%`), hidden: 0 as any},
|
where: {name: Like(`%${value}%`), hidden: 0 as any},
|
||||||
take: limit,
|
take: limit,
|
||||||
|
|
|
@ -1,7 +1,6 @@
|
||||||
import {RouteProp, useFocusEffect, useRoute} from '@react-navigation/native'
|
import {RouteProp, useFocusEffect, useRoute} from '@react-navigation/native'
|
||||||
import {useCallback, useMemo, useRef, useState} from 'react'
|
import {useCallback, useMemo, useRef, useState} from 'react'
|
||||||
import {NativeModules, TextInput, View} from 'react-native'
|
import {FlatList, NativeModules, TextInput, View} from 'react-native'
|
||||||
import {FlatList} from 'react-native-gesture-handler'
|
|
||||||
import {Button, ProgressBar} from 'react-native-paper'
|
import {Button, ProgressBar} from 'react-native-paper'
|
||||||
import {getBestSet} from './best.service'
|
import {getBestSet} from './best.service'
|
||||||
import {PADDING} from './constants'
|
import {PADDING} from './constants'
|
||||||
|
|
10
jestSetup.ts
10
jestSetup.ts
|
@ -9,8 +9,8 @@ jest.mock('react-native-file-access', () => jest.fn())
|
||||||
jest.mock('react-native-share', () => jest.fn())
|
jest.mock('react-native-share', () => jest.fn())
|
||||||
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper')
|
jest.mock('react-native/Libraries/Animated/NativeAnimatedHelper')
|
||||||
jest.useFakeTimers()
|
jest.useFakeTimers()
|
||||||
jest.mock('react-native-reanimated', () => {
|
//jest.mock('react-native-reanimated', () => {
|
||||||
const Reanimated = require('react-native-reanimated/mock')
|
// const Reanimated = require('react-native-reanimated/mock')
|
||||||
Reanimated.default.call = () => {}
|
// Reanimated.default.call = () => {}
|
||||||
return Reanimated
|
// return Reanimated
|
||||||
})
|
//})
|
||||||
|
|
|
@ -61,6 +61,7 @@
|
||||||
"@typescript-eslint/parser": "^5.29.0",
|
"@typescript-eslint/parser": "^5.29.0",
|
||||||
"eslint": "^8.26.0",
|
"eslint": "^8.26.0",
|
||||||
"metro-react-native-babel-preset": "^0.73.3",
|
"metro-react-native-babel-preset": "^0.73.3",
|
||||||
|
"react-native-testing-library": "^6.0.0",
|
||||||
"typescript": "^4.8.4"
|
"typescript": "^4.8.4"
|
||||||
},
|
},
|
||||||
"eslintConfig": {
|
"eslintConfig": {
|
||||||
|
|
57
tests/HomePage.test.tsx
Normal file
57
tests/HomePage.test.tsx
Normal file
|
@ -0,0 +1,57 @@
|
||||||
|
import 'react-native'
|
||||||
|
import React from 'react'
|
||||||
|
import {render} from 'react-native-testing-library'
|
||||||
|
import HomePage from '../HomePage'
|
||||||
|
import {NavigationContainer} from '@react-navigation/native'
|
||||||
|
import {Provider} from 'react-native-paper'
|
||||||
|
import MaterialIcon from 'react-native-vector-icons/MaterialIcons'
|
||||||
|
import SetList from '../SetList'
|
||||||
|
import {Text} from 'react-native'
|
||||||
|
import {AppDataSource} from '../data-source'
|
||||||
|
|
||||||
|
jest.mock('typeorm', () => ({
|
||||||
|
createConnection: jest.fn(() => ({
|
||||||
|
close: jest.fn(),
|
||||||
|
})),
|
||||||
|
Entity: (name: string) => {
|
||||||
|
return (target: any) => {
|
||||||
|
target.name = name
|
||||||
|
}
|
||||||
|
},
|
||||||
|
Column: (type: any) => {
|
||||||
|
return (target: any, propertyName: string) => {
|
||||||
|
target.columns = target.columns || []
|
||||||
|
target.columns.push({
|
||||||
|
propertyName,
|
||||||
|
type,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
PrimaryColumn: () => {
|
||||||
|
return (target: any, propertyName: string) => {
|
||||||
|
target.primaryColumn = {
|
||||||
|
propertyName,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
PrimaryGeneratedColumn: () => {
|
||||||
|
return (target: any, propertyName: string) => {
|
||||||
|
target.primaryColumn = {
|
||||||
|
propertyName,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
}))
|
||||||
|
|
||||||
|
describe('HomePage', () => {
|
||||||
|
it('renders correctly', async () => {
|
||||||
|
const {getByText} = render(
|
||||||
|
<Provider settings={{icon: props => <MaterialIcon {...props} />}}>
|
||||||
|
<NavigationContainer>
|
||||||
|
<SetList />
|
||||||
|
</NavigationContainer>
|
||||||
|
</Provider>,
|
||||||
|
)
|
||||||
|
expect(getByText('Home')).toBeDefined()
|
||||||
|
})
|
||||||
|
})
|
15
yarn.lock
15
yarn.lock
|
@ -7309,6 +7309,7 @@ __metadata:
|
||||||
react-native-sqlite-storage: ^6.0.1
|
react-native-sqlite-storage: ^6.0.1
|
||||||
react-native-svg: ^13.4.0
|
react-native-svg: ^13.4.0
|
||||||
react-native-svg-charts: ^5.4.0
|
react-native-svg-charts: ^5.4.0
|
||||||
|
react-native-testing-library: ^6.0.0
|
||||||
react-native-vector-icons: ^9.2.0
|
react-native-vector-icons: ^9.2.0
|
||||||
react-native-view-shot: ^3.4.0
|
react-native-view-shot: ^3.4.0
|
||||||
react-test-renderer: ^18.2.0
|
react-test-renderer: ^18.2.0
|
||||||
|
@ -8612,7 +8613,7 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
"pretty-format@npm:^26.5.2, pretty-format@npm:^26.6.2":
|
"pretty-format@npm:^26.0.1, pretty-format@npm:^26.5.2, pretty-format@npm:^26.6.2":
|
||||||
version: 26.6.2
|
version: 26.6.2
|
||||||
resolution: "pretty-format@npm:26.6.2"
|
resolution: "pretty-format@npm:26.6.2"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
@ -8980,6 +8981,18 @@ __metadata:
|
||||||
languageName: node
|
languageName: node
|
||||||
linkType: hard
|
linkType: hard
|
||||||
|
|
||||||
|
"react-native-testing-library@npm:^6.0.0":
|
||||||
|
version: 6.0.0
|
||||||
|
resolution: "react-native-testing-library@npm:6.0.0"
|
||||||
|
dependencies:
|
||||||
|
pretty-format: ^26.0.1
|
||||||
|
peerDependencies:
|
||||||
|
react: ">=16.0.0"
|
||||||
|
react-test-renderer: ">=16.0.0"
|
||||||
|
checksum: 291c0e54f29e68733ec73a9ec201991a3ad7d14a8b624ce8e69fdd9306d63198511882a56d8d4ea40349c7a48468fc6eba5cf5043397cbe9974dd9fcd3d37e6a
|
||||||
|
languageName: node
|
||||||
|
linkType: hard
|
||||||
|
|
||||||
"react-native-vector-icons@npm:^9.2.0":
|
"react-native-vector-icons@npm:^9.2.0":
|
||||||
version: 9.2.0
|
version: 9.2.0
|
||||||
resolution: "react-native-vector-icons@npm:9.2.0"
|
resolution: "react-native-vector-icons@npm:9.2.0"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user