Skip to content

Commit 6279eb5

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
Add Fantom integration test for ProgressBarAndroid
Summary: Converts the Jest snapshot test for ProgressBarAndroid to a Fantom integration test, covering rendering with various styleAttr values, determinate/indeterminate progress, animating prop, and testID propagation. Changelog: [Internal] Differential Revision: D94887422
1 parent 48f0c1e commit 6279eb5

2 files changed

Lines changed: 136 additions & 31 deletions

File tree

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict-local
8+
* @format
9+
*/
10+
11+
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
12+
13+
import * as Fantom from '@react-native/fantom';
14+
import * as React from 'react';
15+
// $FlowFixMe[missing-platform-support]
16+
import ProgressBarAndroid from '../ProgressBarAndroid.android';
17+
18+
describe('<ProgressBarAndroid>', () => {
19+
describe('props', () => {
20+
describe('styleAttr and indeterminate', () => {
21+
it('renders with styleAttr="Horizontal" and indeterminate={true}', () => {
22+
const root = Fantom.createRoot();
23+
24+
Fantom.runTask(() => {
25+
root.render(
26+
<ProgressBarAndroid styleAttr="Horizontal" indeterminate={true} />,
27+
);
28+
});
29+
30+
expect(root.getRenderedOutput().toJSX()).toEqual(
31+
<rn-androidProgressBar />,
32+
);
33+
});
34+
35+
it('renders with default props', () => {
36+
const root = Fantom.createRoot();
37+
38+
Fantom.runTask(() => {
39+
root.render(
40+
<ProgressBarAndroid styleAttr="Normal" indeterminate={true} />,
41+
);
42+
});
43+
44+
expect(root.getRenderedOutput().toJSX()).toEqual(
45+
<rn-androidProgressBar />,
46+
);
47+
});
48+
49+
it('renders with styleAttr="Normal"', () => {
50+
const root = Fantom.createRoot();
51+
52+
Fantom.runTask(() => {
53+
root.render(
54+
<ProgressBarAndroid styleAttr="Normal" indeterminate={true} />,
55+
);
56+
});
57+
58+
expect(root.getRenderedOutput().toJSX()).toEqual(
59+
<rn-androidProgressBar />,
60+
);
61+
});
62+
63+
it('renders with styleAttr="Horizontal" and determinate progress', () => {
64+
const root = Fantom.createRoot();
65+
66+
Fantom.runTask(() => {
67+
root.render(
68+
<ProgressBarAndroid
69+
styleAttr="Horizontal"
70+
indeterminate={false}
71+
progress={0.5}
72+
/>,
73+
);
74+
});
75+
76+
expect(root.getRenderedOutput().toJSX()).toEqual(
77+
<rn-androidProgressBar />,
78+
);
79+
});
80+
});
81+
82+
describe('animating', () => {
83+
it('defaults to true', () => {
84+
const root = Fantom.createRoot();
85+
86+
Fantom.runTask(() => {
87+
root.render(
88+
<ProgressBarAndroid styleAttr="Horizontal" indeterminate={true} />,
89+
);
90+
});
91+
92+
expect(root.getRenderedOutput().toJSX()).toEqual(
93+
<rn-androidProgressBar />,
94+
);
95+
});
96+
97+
it('renders when animating is false', () => {
98+
const root = Fantom.createRoot();
99+
100+
Fantom.runTask(() => {
101+
root.render(
102+
<ProgressBarAndroid
103+
styleAttr="Horizontal"
104+
indeterminate={true}
105+
animating={false}
106+
/>,
107+
);
108+
});
109+
110+
expect(root.getRenderedOutput().toJSX()).toEqual(
111+
<rn-androidProgressBar />,
112+
);
113+
});
114+
});
115+
116+
describe('testID', () => {
117+
it('is propagated to the native component', () => {
118+
const root = Fantom.createRoot();
119+
120+
Fantom.runTask(() => {
121+
root.render(
122+
<ProgressBarAndroid
123+
styleAttr="Horizontal"
124+
indeterminate={true}
125+
testID="my-progress-bar"
126+
/>,
127+
);
128+
});
129+
130+
expect(root.getRenderedOutput({props: ['testID']}).toJSX()).toEqual(
131+
<rn-androidProgressBar testID="my-progress-bar" />,
132+
);
133+
});
134+
});
135+
});
136+
});

packages/react-native/Libraries/Components/ProgressBarAndroid/__tests__/ProgressBarAndroid-test.js

Lines changed: 0 additions & 31 deletions
This file was deleted.

0 commit comments

Comments
 (0)