Skip to content

Commit d4ba8ba

Browse files
committed
react-native: remove dead updateScrollYFromEvent and its tests; adjust per-file coverage thresholds for useHeaderStandardAnimated
1 parent 10ba1e0 commit d4ba8ba

3 files changed

Lines changed: 9 additions & 33 deletions

File tree

packages/design-system-react-native/jest.config.js

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@ module.exports = merge(baseConfig, {
2323
statements: 100,
2424
},
2525
// useAnimatedScrollHandler wraps onScroll in a Reanimated worklet; Jest uses the
26-
// reanimated mock, which does not execute that worklet body. Scroll logic is covered
27-
// via updateScrollYFromEvent unit tests, but the hook line that forwards scrollEvent
28-
// into updateScrollYFromEvent stays uncovered here—so statements/lines/functions sit
29-
// below 100% while branches remain fully exercised.
26+
// reanimated mock, which does not execute that worklet body. As a result, the
27+
// inline scroll handler line remains uncovered in unit tests—so statements/lines/
28+
// functions sit below 100% while branches remain fully exercised.
3029
'./src/components/HeaderStandardAnimated/useHeaderStandardAnimated.ts': {
3130
branches: 100,
32-
functions: 75,
33-
lines: 87,
34-
statements: 87,
31+
functions: 66,
32+
lines: 85,
33+
statements: 85,
3534
},
3635
// pressed && !isDisabled branch in getPressableStyle is not unit-testable without
3736
// react-test-renderer internals (see https://github.com/MetaMask/metamask-design-system/issues/1182).

packages/design-system-react-native/src/components/HeaderStandardAnimated/useHeaderStandardAnimated.test.ts

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,8 @@
11
// Third party dependencies.
22
import { renderHook, act } from '@testing-library/react-native';
3-
import type { SharedValue } from 'react-native-reanimated';
43

54
// Internal dependencies.
6-
import {
7-
updateScrollYFromEvent,
8-
useHeaderStandardAnimated,
9-
} from './useHeaderStandardAnimated';
5+
import { useHeaderStandardAnimated } from './useHeaderStandardAnimated';
106

117
jest.mock('react-native-reanimated', () =>
128
jest.requireActual('react-native-reanimated/mock'),
@@ -68,11 +64,6 @@ describe('useHeaderStandardAnimated', () => {
6864
});
6965
});
7066

71-
describe('updateScrollYFromEvent', () => {
72-
it('writes contentOffset.y to the shared value', () => {
73-
const scrollYValue = { value: 0 } as unknown as SharedValue<number>;
74-
updateScrollYFromEvent(scrollYValue, 82);
75-
expect(scrollYValue.value).toBe(82);
76-
});
77-
});
67+
// onScroll is a Reanimated worklet; the jest reanimated mock does not execute
68+
// the worklet body, so the scrollY write is not unit-testable here.
7869
});

packages/design-system-react-native/src/components/HeaderStandardAnimated/useHeaderStandardAnimated.ts

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Third party dependencies.
22
import { useCallback } from 'react';
3-
import type { SharedValue } from 'react-native-reanimated';
43
import {
54
useSharedValue,
65
useAnimatedScrollHandler,
@@ -9,19 +8,6 @@ import {
98
// Internal dependencies.
109
import type { UseHeaderStandardAnimatedReturn } from './HeaderStandardAnimated.types';
1110

12-
/**
13-
* Writes a vertical content offset into the scroll shared value.
14-
*
15-
* @param scrollYValue - Shared value for vertical scroll offset.
16-
* @param contentOffsetY - `contentOffset.y` from the scroll event.
17-
*/
18-
export function updateScrollYFromEvent(
19-
scrollYValue: SharedValue<number>,
20-
contentOffsetY: number,
21-
) {
22-
scrollYValue.value = contentOffsetY;
23-
}
24-
2511
/**
2612
* Hook for managing HeaderStandardAnimated scroll-linked animations.
2713
* Use with HeaderStandardAnimated placed outside the ScrollView as a sibling.

0 commit comments

Comments
 (0)