diff --git a/test/components/common/StatsOverview.spec.js b/test/components/common/StatsOverview.spec.js new file mode 100644 index 0000000..0efe790 --- /dev/null +++ b/test/components/common/StatsOverview.spec.js @@ -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() + + expect(toJSON()).toMatchSnapshot() + }) + + test('when provided empty data, renders nothing (does not break)', async () => { + const data = [] + const { toJSON } = render() + + expect(toJSON()).toMatchSnapshot() + }) +}) diff --git a/test/components/common/__snapshots__/StatsOverview.spec.js.snap b/test/components/common/__snapshots__/StatsOverview.spec.js.snap new file mode 100644 index 0000000..60ca8e2 --- /dev/null +++ b/test/components/common/__snapshots__/StatsOverview.spec.js.snap @@ -0,0 +1,321 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`StatsOverview screen when provided correct, renders it 1`] = ` +Array [ + + + + 21 + + + + + shortest + + + , + + + + 21 + + + + + longest + + + , + + + + 0 + + + + + standard deviation + + + * + + + , + + + + 2 + + + + + completed cycles + + + , +] +`; + +exports[`StatsOverview screen when provided empty data, renders nothing (does not break) 1`] = `null`;