Skip to content

Commit

Permalink
add DateSelect rendering unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
jiji14 committed May 30, 2024
1 parent 1bd1f48 commit e55e5ae
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions www/__tests__/DateSelect.test.tsx
Original file line number Diff line number Diff line change
@@ -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(<DateSelect mode="range" onChoose={onChooseMock} />);

expect(screen.getByTestId('button-container')).toBeTruthy();
expect(screen.getByTestId('button')).toBeTruthy();
});
});

0 comments on commit e55e5ae

Please sign in to comment.