Add tests for StatsOverview component
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
import React from 'react'
|
||||
import { render } from '@testing-library/react-native'
|
||||
import StatsOverview from '../../../components/common/StatsOverview'
|
||||
|
||||
jest.mock('react-i18next', () => ({
|
||||
useTranslation: () => ({
|
||||
t: (str, options) => {
|
||||
return str + (options ? JSON.stringify(options) : '')
|
||||
},
|
||||
}),
|
||||
}))
|
||||
|
||||
describe('StatsOverview screen', () => {
|
||||
test('when provided correct, renders it', async () => {
|
||||
const data = [
|
||||
[21, 'shortest'],
|
||||
[21, 'longest'],
|
||||
[0, 'standard deviation'],
|
||||
[2, 'completed cycles'],
|
||||
]
|
||||
const { toJSON } = render(<StatsOverview data={data} />)
|
||||
|
||||
expect(toJSON()).toMatchSnapshot()
|
||||
})
|
||||
|
||||
test('when provided empty data, renders nothing (does not break)', async () => {
|
||||
const data = []
|
||||
const { toJSON } = render(<StatsOverview data={data} />)
|
||||
|
||||
expect(toJSON()).toMatchSnapshot()
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user