Skip to content

Commit

Permalink
Merge pull request #37049 from callstack-internal/pac-guerreiro/refac…
Browse files Browse the repository at this point in the history
…tor/migrate-calendarpickertest-to-typescript

[No QA][TS migration] Migrate 'CalendarPickerTest.js' test to TypeScript
  • Loading branch information
pecanoro authored Mar 1, 2024
2 parents c061c11 + b6966a7 commit 6b458fb
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
2 changes: 1 addition & 1 deletion jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ module.exports = {
},
testEnvironment: 'jsdom',
setupFiles: ['<rootDir>/jest/setup.ts', './node_modules/@react-native-google-signin/google-signin/jest/build/setup.js'],
setupFilesAfterEnv: ['@testing-library/jest-native/extend-expect', '<rootDir>/jest/setupAfterEnv.ts', '<rootDir>/tests/perf-test/setupAfterEnv.js'],
setupFilesAfterEnv: ['<rootDir>/jest/setupAfterEnv.ts', '<rootDir>/tests/perf-test/setupAfterEnv.js'],
cacheDirectory: '<rootDir>/.jest-cache',
moduleNameMapper: {
'\\.(lottie)$': '<rootDir>/__mocks__/fileMock.ts',
Expand Down
3 changes: 3 additions & 0 deletions jest/setupAfterEnv.ts
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
// This is required in order for jest to recognize custom matchers like toBeDisabled. This can be removed once testing-library/react-native version is bumped to v12.4 or later
import '@testing-library/jest-native/extend-expect';

jest.useRealTimers();
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
import type ReactNavigationNative from '@react-navigation/native';
import {fireEvent, render, within} from '@testing-library/react-native';
import {addMonths, addYears, subMonths, subYears} from 'date-fns';
import CalendarPicker from '../../src/components/DatePicker/CalendarPicker';
import CONST from '../../src/CONST';
import DateUtils from '../../src/libs/DateUtils';
import type {ComponentType} from 'react';
import CalendarPicker from '@components/DatePicker/CalendarPicker';
import type {WithLocalizeProps} from '@components/withLocalize';
import DateUtils from '@libs/DateUtils';
import CONST from '@src/CONST';

const monthNames = DateUtils.getMonthNames(CONST.LOCALES.EN);

jest.mock('@react-navigation/native', () => ({
...jest.requireActual('@react-navigation/native'),
...jest.requireActual<typeof ReactNavigationNative>('@react-navigation/native'),
useNavigation: () => ({navigate: jest.fn()}),
createNavigationContainerRef: jest.fn(),
}));

jest.mock('../../src/components/withLocalize', () => (Component) => {
function WrappedComponent(props) {
jest.mock('../../src/components/withLocalize', () => (Component: ComponentType<WithLocalizeProps>) => {
function WrappedComponent(props: Omit<WithLocalizeProps, 'translate' | 'preferredLocale'>) {
return (
<Component
// eslint-disable-next-line react/jsx-props-no-spreading
Expand Down

0 comments on commit 6b458fb

Please sign in to comment.