Skip to content

Commit 6902d94

Browse files
committed
Fixed test errors
1 parent 266d0b4 commit 6902d94

File tree

4 files changed

+65
-42
lines changed

4 files changed

+65
-42
lines changed

app/components/UI/Carousel/StackCard/StackCard.test.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ jest.mock('@metamask/design-system-react-native', () => ({
3333
IconName: {
3434
Close: 'close',
3535
},
36+
IconColor: {
37+
Alternative: 'Alternative',
38+
IconDefault: 'IconDefault',
39+
Default: 'Default',
40+
},
3641
}));
3742

3843
describe('StackCard', () => {

app/components/UI/Carousel/StackCard/StackCard.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ import {
1414
ButtonIcon,
1515
ButtonIconSize,
1616
IconName,
17-
IconColor,
17+
IconColor as MMDSIconColor,
1818
} from '@metamask/design-system-react-native';
1919
import { useTailwind } from '@metamask/design-system-twrnc-preset';
2020
import { StackCardProps } from './StackCard.types';
@@ -149,7 +149,7 @@ export const StackCard: React.FC<StackCardProps> = ({
149149
<ButtonIcon
150150
iconName={IconName.Close}
151151
size={ButtonIconSize.Md}
152-
iconColor={IconColor.Alternative}
152+
iconProps={{ color: MMDSIconColor.IconDefault }}
153153
onPress={() => onTransitionToNextCard?.()}
154154
testID={`carousel-slide-${slide.id}-close-button`}
155155
hitSlop={{ top: 8, bottom: 8, left: 8, right: 8 }}

app/components/UI/Carousel/animations/useTransitionToEmpty.test.ts

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,35 @@ import { renderHook } from '@testing-library/react-hooks';
22
import { Animated } from 'react-native';
33
import { useTransitionToEmpty } from './useTransitionToEmpty';
44

5-
// Mock Animated
6-
jest.mock('react-native', () => ({
7-
Animated: {
8-
Value: jest.fn(() => ({
9-
setValue: jest.fn(),
10-
addListener: jest.fn(),
11-
removeAllListeners: jest.fn(),
12-
})),
13-
timing: jest.fn(() => ({
14-
start: jest.fn((callback) => callback && callback()),
15-
})),
16-
parallel: jest.fn(() => ({
17-
start: jest.fn((callback) => callback && callback()),
18-
})),
19-
sequence: jest.fn(() => ({
20-
start: jest.fn((callback) => callback && callback()),
21-
})),
22-
delay: jest.fn(),
23-
},
24-
}));
5+
// Mock Animated and Easing
6+
jest.mock('react-native', () => {
7+
const MockEasing = {
8+
out: jest.fn((fn) => fn),
9+
cubic: jest.fn(),
10+
bezier: jest.fn(() => jest.fn()),
11+
};
12+
13+
return {
14+
Animated: {
15+
Value: jest.fn(() => ({
16+
setValue: jest.fn(),
17+
addListener: jest.fn(),
18+
removeAllListeners: jest.fn(),
19+
})),
20+
timing: jest.fn(() => ({
21+
start: jest.fn((callback) => callback?.()),
22+
})),
23+
parallel: jest.fn(() => ({
24+
start: jest.fn((callback) => callback?.()),
25+
})),
26+
sequence: jest.fn(() => ({
27+
start: jest.fn((callback) => callback?.()),
28+
})),
29+
delay: jest.fn(),
30+
},
31+
Easing: MockEasing,
32+
};
33+
});
2534

2635
jest.mock('./animationTimings', () => ({
2736
ANIMATION_TIMINGS: {

app/components/UI/Carousel/animations/useTransitionToNextCard.test.ts

Lines changed: 29 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,35 @@ import { renderHook } from '@testing-library/react-hooks';
22
import { Animated } from 'react-native';
33
import { useTransitionToNextCard } from './useTransitionToNextCard';
44

5-
// Mock Animated
6-
jest.mock('react-native', () => ({
7-
Animated: {
8-
Value: jest.fn(() => ({
9-
setValue: jest.fn(),
10-
addListener: jest.fn(),
11-
removeAllListeners: jest.fn(),
12-
})),
13-
timing: jest.fn(() => ({
14-
start: jest.fn((callback) => callback && callback()),
15-
})),
16-
parallel: jest.fn(() => ({
17-
start: jest.fn((callback) => callback && callback()),
18-
})),
19-
sequence: jest.fn(() => ({
20-
start: jest.fn((callback) => callback && callback()),
21-
})),
22-
delay: jest.fn(),
23-
},
24-
}));
5+
// Mock Animated and Easing
6+
jest.mock('react-native', () => {
7+
const MockEasing = {
8+
out: jest.fn((fn) => fn),
9+
cubic: jest.fn(),
10+
bezier: jest.fn(() => jest.fn()),
11+
};
12+
13+
return {
14+
Animated: {
15+
Value: jest.fn(() => ({
16+
setValue: jest.fn(),
17+
addListener: jest.fn(),
18+
removeAllListeners: jest.fn(),
19+
})),
20+
timing: jest.fn(() => ({
21+
start: jest.fn((callback) => callback?.()),
22+
})),
23+
parallel: jest.fn(() => ({
24+
start: jest.fn((callback) => callback?.()),
25+
})),
26+
sequence: jest.fn(() => ({
27+
start: jest.fn((callback) => callback?.()),
28+
})),
29+
delay: jest.fn(),
30+
},
31+
Easing: MockEasing,
32+
};
33+
});
2534

2635
jest.mock('./animationTimings', () => ({
2736
ANIMATION_TIMINGS: {

0 commit comments

Comments
 (0)