Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 19 additions & 16 deletions app/components/UI/Rewards/RewardsNavigator.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,22 +70,25 @@ jest.mock('./Views/RewardsSettingsView', () => {
});

// Mock Skeleton component
jest.mock('../../../component-library/components/Skeleton/Skeleton', () => {
const ReactActual = jest.requireActual('react');
const { View } = jest.requireActual('react-native');
return function MockSkeleton({
width,
height,
}: {
width: string;
height: string;
}) {
return ReactActual.createElement(View, {
testID: 'skeleton-loader',
style: { width, height },
});
};
});
jest.mock(
'../../../component-library/components-temp/Skeleton/Skeleton',
() => {
const React = jest.requireActual('react');
const { View } = jest.requireActual('react-native');
return function MockSkeleton({
width,
height,
}: {
width: string;
height: string;
}) {
return React.createElement(View, {
testID: 'skeleton-loader',
style: { width, height },
});
};
},
);

// Mock ErrorBoundary
jest.mock('../../Views/ErrorBoundary', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import {
TextVariant,
} from '@metamask/design-system-react-native';

import { Skeleton } from '../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../component-library/components-temp/Skeleton';

import {
setOnboardingActiveStep,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import React from 'react';
import { render } from '@testing-library/react-native';
import { Text } from 'react-native';
import PreviousSeasonSummaryTile from './PreviousSeasonSummaryTile';
import { SkeletonProps } from '../../../../../component-library/components/Skeleton';
import { SkeletonProps } from '../../../../../component-library/components-temp/Skeleton';

// Mock Skeleton
jest.mock('../../../../../component-library/components/Skeleton', () => {
jest.mock('../../../../../component-library/components-temp/Skeleton', () => {
const ReactActual = jest.requireActual('react');
const { View } = jest.requireActual('react-native');
return {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Box } from '@metamask/design-system-react-native';
import React, { PropsWithChildren } from 'react';
import { Skeleton } from '../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../component-library/components-temp/Skeleton';

interface PreviousSeasonSummaryTileProps extends PropsWithChildren {
twClassName?: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ jest.mock('@metamask/design-system-react-native', () => {
});

// Mock Skeleton
jest.mock('../../../../../component-library/components/Skeleton', () => {
jest.mock('../../../../../component-library/components-temp/Skeleton', () => {
const ReactActual = jest.requireActual('react');
const { View } = jest.requireActual('react-native');
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import {
import { useUnlockedRewards } from '../../hooks/useUnlockedRewards';
import RewardsSeasonEndedNoUnlockedRewardsImage from '../../../../../images/rewards/rewards-season-ended-no-unlocked-rewards.svg';
import RewardsErrorBanner from '../RewardsErrorBanner';
import { Skeleton } from '../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../component-library/components-temp/Skeleton';
import { useTailwind } from '@metamask/design-system-twrnc-preset';
import RewardItem from '../RewardItem/RewardItem';
import { useTheme } from '../../../../../util/theme';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
IconColor,
IconName,
} from '../../../../../component-library/components/Icons/Icon/Icon.types';
import { Skeleton } from '../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../component-library/components-temp/Skeleton';

interface CopyableFieldProps {
label: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ jest.mock(
);

// Mock the Skeleton component
jest.mock('../../../../../component-library/components/Skeleton', () => {
jest.mock('../../../../../component-library/components-temp/Skeleton', () => {
const mockReact = jest.requireActual('react');
const RN = jest.requireActual('react-native');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
TextVariant,
} from '@metamask/design-system-react-native';
import MetamaskRewardsPointsImage from '../../../../../images/rewards/metamask-rewards-points.svg';
import { Skeleton } from '../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../component-library/components-temp/Skeleton';
import { SeasonWayToEarnSpecificReferralDto } from '../../../../../core/Engine/controllers/rewards-controller/types';
import { strings } from '../../../../../../locales/i18n';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ jest.mock('../../../../../images/rewards/metamask-rewards-points.svg', () => {
});

// Mock Skeleton component
jest.mock('../../../../../component-library/components/Skeleton', () => {
jest.mock('../../../../../component-library/components-temp/Skeleton', () => {
const ReactActual = jest.requireActual('react');
const { View } = jest.requireActual('react-native');
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { strings } from '../../../../../../locales/i18n';
import { useTheme } from '../../../../../util/theme';
import MetamaskRewardsPointsImage from '../../../../../images/rewards/metamask-rewards-points.svg';
import { Skeleton } from '../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../component-library/components-temp/Skeleton';
import { useSelector } from 'react-redux';
import {
selectSeasonStatusLoading,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ jest.mock('../../../../../component-library/components/Buttons/Button', () => {
};
});

jest.mock('../../../../../component-library/components/Skeleton', () => {
jest.mock('../../../../../component-library/components-temp/Skeleton', () => {
const ReactActual = jest.requireActual('react');
const { View } = jest.requireActual('react-native');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
REFERRAL_CODE_LENGTH,
} from '../../hooks/useValidateReferralCode';
import { useApplyReferralCode } from '../../hooks/useApplyReferralCode';
import { Skeleton } from '../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../component-library/components-temp/Skeleton';
import { useTheme } from '../../../../../util/theme';
import RewardsErrorBanner from '../RewardsErrorBanner';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -266,7 +266,7 @@ jest.mock('@metamask/design-system-react-native', () => {
});

// Mock Skeleton component
jest.mock('../../../../../component-library/components/Skeleton', () => {
jest.mock('../../../../../component-library/components-temp/Skeleton', () => {
const ReactActual = jest.requireActual('react');
const { View } = jest.requireActual('react-native');

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
IconColor,
} from '@metamask/design-system-react-native';
import { strings } from '../../../../../../locales/i18n';
import { Skeleton } from '../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../component-library/components-temp/Skeleton';
import { useRewardOptinSummary } from '../../hooks/useRewardOptinSummary';
import { selectAvatarAccountType } from '../../../../../selectors/settings';
import { selectInternalAccountsByGroupId } from '../../../../../selectors/multichainAccounts/accounts';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
selectSeasonStatusLoading,
selectSeasonActivityTypes,
} from '../../../../../../reducers/rewards/selectors';
import { Skeleton } from '../../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../../component-library/components-temp/Skeleton';
import MetamaskRewardsActivityEmptyImage from '../../../../../../images/rewards/metamask-rewards-activity-empty.svg';
import RewardsErrorBanner from '../../RewardsErrorBanner';
import { setActiveTab } from '../../../../../../actions/rewards';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
selectCurrentTier,
} from '../../../../../../reducers/rewards/selectors';
import { useUnlockedRewards } from '../../../hooks/useUnlockedRewards';
import { SkeletonProps } from '../../../../../../component-library/components/Skeleton';
import { SkeletonProps } from '../../../../../../component-library/components-temp/Skeleton';

// Mock dependencies
jest.mock('react-redux', () => ({
Expand Down Expand Up @@ -84,19 +84,22 @@ jest.mock('../../../../../../../locales/i18n', () => ({
jest.mock('../../RewardItem/RewardItem', () => jest.fn(() => null));

// Mock Skeleton
jest.mock('../../../../../../component-library/components/Skeleton', () => {
const ReactActual = jest.requireActual('react');
const { View } = jest.requireActual('react-native');
return {
__esModule: true,
Skeleton: ({ style, ...props }: SkeletonProps) =>
ReactActual.createElement(View, {
testID: 'skeleton',
style,
...props,
}),
};
});
jest.mock(
'../../../../../../component-library/components-temp/Skeleton',
() => {
const ReactActual = jest.requireActual('react');
const { View } = jest.requireActual('react-native');
return {
__esModule: true,
Skeleton: ({ style, ...props }: SkeletonProps) =>
ReactActual.createElement(View, {
testID: 'skeleton',
style,
...props,
}),
};
},
);

// Mock the useUnlockedRewards hook
jest.mock('../../../hooks/useUnlockedRewards', () => ({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useTailwind } from '@metamask/design-system-twrnc-preset';
import { REWARDS_VIEW_SELECTORS } from '../../../Views/RewardsView.constants';
import RewardItem from '../../RewardItem/RewardItem';
import { useUnlockedRewards } from '../../../hooks/useUnlockedRewards';
import { Skeleton } from '../../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../../component-library/components-temp/Skeleton';
import RewardsErrorBanner from '../../RewardsErrorBanner';
import { ActivityIndicator } from 'react-native';
interface UnlockedRewardItemProps {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import { REWARDS_VIEW_SELECTORS } from '../../../Views/RewardsView.constants';
import RewardItem from '../../RewardItem/RewardItem';
import RewardsThemeImageComponent from '../../ThemeImageComponent';
import RewardsErrorBanner from '../../RewardsErrorBanner';
import { Skeleton } from '../../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../../component-library/components-temp/Skeleton';
import RewardsImageModal from '../../RewardsImageModal';
import fallbackTierImage from '../../../../../../images/rewards/tiers/rewards-s1-tier-1.png';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { configureStore } from '@reduxjs/toolkit';
import ActiveBoosts from './ActiveBoosts';
import { REWARDS_VIEW_SELECTORS } from '../../../Views/RewardsView.constants';
import { PointsBoostDto } from '../../../../../../core/Engine/controllers/rewards-controller/types';
import { SkeletonProps } from '../../../../../../component-library/components/Skeleton';
import { SkeletonProps } from '../../../../../../component-library/components-temp/Skeleton';

// Mock dependencies
const mockUseTheme = jest.fn(() => ({
Expand Down Expand Up @@ -81,12 +81,15 @@ jest.mock('../../../utils/formatUtils', () => ({
}),
}));

jest.mock('../../../../../../component-library/components/Skeleton', () => ({
Skeleton: ({ testID, ...props }: SkeletonProps) => {
const { View } = jest.requireActual('react-native');
return <View testID={testID || 'skeleton'} {...props} />;
},
}));
jest.mock(
'../../../../../../component-library/components-temp/Skeleton',
() => ({
Skeleton: ({ testID, ...props }: SkeletonProps) => {
const { View } = jest.requireActual('react-native');
return <View testID={testID || 'skeleton'} {...props} />;
},
}),
);

// Mock RewardsThemeImageComponent
jest.mock('../../ThemeImageComponent', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
} from '../../../../Bridge/hooks/useSwapBridgeNavigation';
import { REWARDS_VIEW_SELECTORS } from '../../../Views/RewardsView.constants';
import { formatTimeRemaining } from '../../../utils/formatUtils';
import { Skeleton } from '../../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../../component-library/components-temp/Skeleton';
import RewardsThemeImageComponent from '../../ThemeImageComponent';
import RewardsErrorBanner from '../../RewardsErrorBanner';
import { MetaMetricsEvents, useMetrics } from '../../../../../hooks/useMetrics';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,17 +44,20 @@ jest.mock('../../../../components/SnapshotTile', () => {
};
});

jest.mock('../../../../../../../component-library/components/Skeleton', () => {
const ReactNative = jest.requireActual('react-native');
const ReactActual = jest.requireActual('react');
return {
Skeleton: jest.fn(() =>
ReactActual.createElement(ReactNative.View, {
testID: 'skeleton-loader',
}),
),
};
});
jest.mock(
'../../../../../../../component-library/components-temp/Skeleton',
() => {
const ReactNative = jest.requireActual('react-native');
const ReactActual = jest.requireActual('react');
return {
Skeleton: jest.fn(() =>
ReactActual.createElement(ReactNative.View, {
testID: 'skeleton-loader',
}),
),
};
},
);

jest.mock('../../../../components/RewardsErrorBanner', () => {
const ReactNative = jest.requireActual('react-native');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {
SnapshotTile,
UpcomingSnapshotTileCondensed,
} from '../../../../components/SnapshotTile';
import { Skeleton } from '../../../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../../../component-library/components-temp/Skeleton';
import RewardsErrorBanner from '../../../../components/RewardsErrorBanner';
import { REWARDS_VIEW_SELECTORS } from '../../../../Views/RewardsView.constants';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,12 @@ jest.mock('@metamask/design-system-twrnc-preset', () => ({
}),
}));

jest.mock('../../../../../../component-library/components/Skeleton', () => ({
Skeleton: 'Skeleton',
}));
jest.mock(
'../../../../../../component-library/components-temp/Skeleton',
() => ({
Skeleton: 'Skeleton',
}),
);

jest.mock('../../RewardsErrorBanner', () => ({
__esModule: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
import { useTailwind } from '@metamask/design-system-twrnc-preset';
import { strings } from '../../../../../../../locales/i18n';
import { useSnapshots } from '../../../hooks/useSnapshots';
import { Skeleton } from '../../../../../../component-library/components/Skeleton';
import { Skeleton } from '../../../../../../component-library/components-temp/Skeleton';
import RewardsErrorBanner from '../../RewardsErrorBanner';
import { REWARDS_VIEW_SELECTORS } from '../../../Views/RewardsView.constants';
import SnapshotsGroup from './SnapshotsGroup';
Expand Down
Loading