diff --git a/components/stats.js b/components/stats.js
index ef061b6..be32473 100644
--- a/components/stats.js
+++ b/components/stats.js
@@ -77,7 +77,10 @@ const Stats = () => {
{isStatsVisible && (
setIsStatsVisible(false)}>
- setIsStatsVisible(false)} />
+ setIsStatsVisible(false)}
+ testID="statsTable"
+ />
)}
diff --git a/test/components/stats.spec.js b/test/components/stats.spec.js
index 4eaaa89..fa55366 100644
--- a/test/components/stats.spec.js
+++ b/test/components/stats.spec.js
@@ -1,5 +1,5 @@
import React from 'react'
-import { render } from '@testing-library/react-native'
+import { fireEvent, render } from '@testing-library/react-native'
import Stats from '../../components/stats'
@@ -13,6 +13,7 @@ const mockGetAllCycleLengths = jest
.mockImplementationOnce(() => [30, 31, 30])
.mockImplementationOnce(() => null)
.mockImplementationOnce(() => undefined)
+ .mockImplementationOnce(() => [30, 31, 30])
jest.mock('../../lib/cycle', () => ({
__esModule: true,
@@ -45,4 +46,13 @@ describe('Stats screen', () => {
expect(toJSON()).toMatchSnapshot()
})
+
+ test('when button is clicked, StatsTable is rendered', async () => {
+ const { getByText, findByTestId } = render()
+ const button = getByText('show_stats')
+
+ fireEvent(button, 'click')
+
+ await expect(findByTestId('statsTable')).toBeTruthy()
+ })
})