Skip to content

Commit 43f77af

Browse files
authored
Extract and reuse test components (#380)
* Create <TestPolyfill> * Use <TestPolyfill> in 0.65 and 0.66
1 parent 5821b8c commit 43f77af

File tree

3 files changed

+34
-44
lines changed

3 files changed

+34
-44
lines changed

platforms/detox/TestPolyfill.js

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import React from 'react';
2+
import {Text} from 'react-native';
3+
4+
const PolyfillTests = () => (
5+
<>
6+
<Text testID="url-polyfill-version">
7+
{global.REACT_NATIVE_URL_POLYFILL}
8+
</Text>
9+
<Text testID="url-test-1">{new URL('dev', 'https://google.dev').href}</Text>
10+
<Text testID="url-test-2">
11+
{
12+
new URL('https://facebook.github.io/react-native/img/header_logo.png')
13+
.href
14+
}
15+
</Text>
16+
<Text testID="url-test-3">
17+
{URL.createObjectURL({
18+
data: {
19+
blobId: 1,
20+
offset: 32,
21+
},
22+
size: 64,
23+
})}
24+
</Text>
25+
</>
26+
);
27+
28+
export default PolyfillTests;

platforms/react-native/0.65/App.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,33 +9,14 @@
99
import React from 'react';
1010
import {SafeAreaView, Text, StatusBar} from 'react-native';
1111

12+
import TestPolyfill from '../../detox/TestPolyfill';
13+
1214
const App: () => React$Node = () => {
1315
return (
1416
<>
1517
<StatusBar barStyle="dark-content" />
1618
<SafeAreaView>
17-
<Text testID="url-polyfill-version">
18-
{global.REACT_NATIVE_URL_POLYFILL}
19-
</Text>
20-
<Text testID="url-test-1">
21-
{new URL('dev', 'https://google.dev').href}
22-
</Text>
23-
<Text testID="url-test-2">
24-
{
25-
new URL(
26-
'https://facebook.github.io/react-native/img/header_logo.png',
27-
).href
28-
}
29-
</Text>
30-
<Text testID="url-test-3">
31-
{URL.createObjectURL({
32-
data: {
33-
blobId: 1,
34-
offset: 32,
35-
},
36-
size: 64,
37-
})}
38-
</Text>
19+
<TestPolyfill />
3920
</SafeAreaView>
4021
</>
4122
);

platforms/react-native/0.66/App.js

Lines changed: 3 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -10,33 +10,14 @@ import React from 'react';
1010
import type {Node} from 'react';
1111
import {SafeAreaView, Text, StatusBar} from 'react-native';
1212

13+
import TestPolyfill from '../../detox/TestPolyfill';
14+
1315
const App: () => Node = () => {
1416
return (
1517
<>
1618
<StatusBar barStyle="dark-content" />
1719
<SafeAreaView>
18-
<Text testID="url-polyfill-version">
19-
{global.REACT_NATIVE_URL_POLYFILL}
20-
</Text>
21-
<Text testID="url-test-1">
22-
{new URL('dev', 'https://google.dev').href}
23-
</Text>
24-
<Text testID="url-test-2">
25-
{
26-
new URL(
27-
'https://facebook.github.io/react-native/img/header_logo.png',
28-
).href
29-
}
30-
</Text>
31-
<Text testID="url-test-3">
32-
{URL.createObjectURL({
33-
data: {
34-
blobId: 1,
35-
offset: 32,
36-
},
37-
size: 64,
38-
})}
39-
</Text>
20+
<TestPolyfill />
4021
</SafeAreaView>
4122
</>
4223
);

0 commit comments

Comments
 (0)