/
githubmr
/
facebook-react-native
Обзор
Документация
Войти
/
githubmr
/
facebook-react-native
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
main
packages/react-native/Libraries/Animated/__tests__/AnimatedBackend-itest.js
75 строк
2 KB
Bartlomiej Bloniarz
boostrap shared animation backend (#53994)
01 окт 2025, 14:15
01 окт 2025, 14:15
325c681
Код
Авторство
О чём код?
/** * Copyright (c) Meta Platforms, Inc. and affiliates. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. * * @fantom_flags useSharedAnimatedBackend:true * @flow strict-local * @format */ import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment'; import type {HostInstance} from 'react-native'; import ensureInstance from '../../../src/private/__tests__/utilities/ensureInstance'; import * as Fantom from '@react-native/fantom'; import {createRef} from 'react'; import {Animated, useAnimatedValue} from 'react-native'; import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement'; test('animated opacity', () => { let _opacity; let _opacityAnimation; const viewRef = createRef<HostInstance>(); function MyApp() { const opacity = useAnimatedValue(1); _opacity = opacity; return ( <Animated.View ref={viewRef} style={[ { width: 100, height: 100, opacity: opacity, }, ]} /> ); } const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(<MyApp />); }); const viewElement = ensureInstance(viewRef.current, ReactNativeElement); expect(viewElement.getBoundingClientRect().x).toBe(0); Fantom.runTask(() => { _opacityAnimation = Animated.timing(_opacity, { toValue: 0, duration: 30, useNativeDriver: true, }).start(); }); Fantom.unstable_produceFramesForDuration(30); expect(Fantom.unstable_getDirectManipulationProps(viewElement).opacity).toBe( 0, ); // TODO: this shouldn't be neccessary since animation should be stopped after duration Fantom.runTask(() => { _opacityAnimation?.stop(); }); expect(root.getRenderedOutput({props: ['opacity']}).toJSX()).toEqual( <rn-view opacity="0" />, ); });