From e55e5ae7c194f21b02cef130ad2a126a27b128b4 Mon Sep 17 00:00:00 2001 From: Jijeong Lee Date: Wed, 29 May 2024 20:13:30 -0700 Subject: [PATCH] add DateSelect rendering unit test --- www/__tests__/DateSelect.test.tsx | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 www/__tests__/DateSelect.test.tsx diff --git a/www/__tests__/DateSelect.test.tsx b/www/__tests__/DateSelect.test.tsx new file mode 100644 index 000000000..79fdc1997 --- /dev/null +++ b/www/__tests__/DateSelect.test.tsx @@ -0,0 +1,19 @@ +import React from 'react'; +import { render, screen } from '@testing-library/react-native'; +import DateSelect from '../js/diary/list/DateSelect'; + +jest.mock('react-native-safe-area-context', () => ({ + useSafeAreaInsets: () => ({ bottom: 30, left: 0, right: 0, top: 30 }), +})); +jest.spyOn(React, 'useState').mockImplementation((initialValue) => [initialValue, jest.fn()]); +jest.spyOn(React, 'useEffect').mockImplementation((effect: () => void) => effect()); + +describe('DateSelect', () => { + it('renders correctly', () => { + const onChooseMock = jest.fn(); + const { getByText } = render(); + + expect(screen.getByTestId('button-container')).toBeTruthy(); + expect(screen.getByTestId('button')).toBeTruthy(); + }); +});