Skip to content

Commit 8ed0fa8

Browse files
rubennortefacebook-github-bot
authored andcommitted
Remove unnecessary references to internal types in performance tests (#53427)
Summary: Pull Request resolved: #53427 Changelog: [internal] Migrate the imported types to the globally defined ones, so we follow the good practice of only accessing the public API in Fantom tests. Reviewed By: rshest Differential Revision: D80807160 fbshipit-source-id: 77d792b56b53c8da8409dd9133cd111afb8084f1
1 parent 05be374 commit 8ed0fa8

File tree

5 files changed

+4
-35
lines changed

5 files changed

+4
-35
lines changed

packages/react-native/src/private/webapis/performance/__tests__/EventTimingAPI-itest.js

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,24 +10,17 @@
1010

1111
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
1212

13-
import type Performance from 'react-native/src/private/webapis/performance/Performance';
14-
import type {PerformanceObserverEntryList} from 'react-native/src/private/webapis/performance/PerformanceObserver';
15-
1613
import MaybeNativePerformance from '../specs/NativePerformance';
1714
import * as Fantom from '@react-native/fantom';
1815
import nullthrows from 'nullthrows';
1916
import {useState} from 'react';
2017
import {Text, View} from 'react-native';
2118
import setUpPerformanceObserver from 'react-native/src/private/setup/setUpPerformanceObserver';
22-
import {PerformanceEventTiming} from 'react-native/src/private/webapis/performance/EventTiming';
23-
import {PerformanceObserver} from 'react-native/src/private/webapis/performance/PerformanceObserver';
2419

2520
const NativePerformance = nullthrows(MaybeNativePerformance);
2621

2722
setUpPerformanceObserver();
2823

29-
declare var performance: Performance;
30-
3124
function sleep(ms: number) {
3225
const end = performance.now() + ms;
3326
while (performance.now() < end) {}

packages/react-native/src/private/webapis/performance/__tests__/LongTasksAPI-itest.js

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,15 +10,10 @@
1010

1111
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
1212

13-
import type {
14-
PerformanceObserverCallbackOptions,
15-
PerformanceObserverEntryList,
16-
} from 'react-native/src/private/webapis/performance/PerformanceObserver';
13+
import type {PerformanceObserverCallbackOptions} from '../PerformanceObserver';
1714

1815
import * as Fantom from '@react-native/fantom';
1916
import setUpPerformanceObserver from 'react-native/src/private/setup/setUpPerformanceObserver';
20-
import {PerformanceLongTaskTiming} from 'react-native/src/private/webapis/performance/LongTasks';
21-
import {PerformanceObserver} from 'react-native/src/private/webapis/performance/PerformanceObserver';
2217

2318
setUpPerformanceObserver();
2419

packages/react-native/src/private/webapis/performance/__tests__/Performance-benchmark-itest.js

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,12 +10,8 @@
1010

1111
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
1212

13-
import type Performance from 'react-native/src/private/webapis/performance/Performance';
14-
1513
import * as Fantom from '@react-native/fantom';
1614

17-
declare var performance: Performance;
18-
1915
const clearMarksAndMeasures = () => {
2016
performance.clearMarks();
2117
performance.clearMeasures();

packages/react-native/src/private/webapis/performance/__tests__/PerformanceObserver-itest.js

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,11 @@
1010

1111
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
1212

13-
import type Performance from '../Performance';
14-
import type {
15-
PerformanceObserver as PerformanceObserverT,
16-
PerformanceObserverEntryList,
17-
} from '../PerformanceObserver';
18-
1913
import setUpPerformanceObserver from '../../../setup/setUpPerformanceObserver';
2014
import * as Fantom from '@react-native/fantom';
2115

2216
setUpPerformanceObserver();
2317

24-
declare var performance: Performance;
25-
declare var PerformanceObserver: Class<PerformanceObserverT>;
26-
2718
describe('PerformanceObserver', () => {
2819
it('receives notifications for marks and measures', () => {
2920
const callback = jest.fn();

packages/react-native/src/private/webapis/performance/__tests__/UserTiming-itest.js

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,18 +10,12 @@
1010

1111
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
1212

13-
import type Performance from '../Performance';
14-
import type {
15-
PerformanceEntryJSON,
16-
PerformanceEntryList,
17-
} from '../PerformanceEntry';
18-
1913
import ensureInstance from '../../../__tests__/utilities/ensureInstance';
14+
import setUpPerformanceObserver from '../../../setup/setUpPerformanceObserver';
2015
import DOMException from '../../errors/DOMException';
21-
import {PerformanceMark, PerformanceMeasure} from '../UserTiming';
2216
import * as Fantom from '@react-native/fantom';
2317

24-
declare var performance: Performance;
18+
setUpPerformanceObserver();
2519

2620
function getThrownError(fn: () => mixed): mixed {
2721
try {
@@ -32,7 +26,7 @@ function getThrownError(fn: () => mixed): mixed {
3226
throw new Error('Expected function to throw');
3327
}
3428

35-
function toJSON(entries: PerformanceEntryList): Array<PerformanceEntryJSON> {
29+
function toJSON(entries: PerformanceEntryList): Array<mixed> {
3630
return entries.map(entry => entry.toJSON());
3731
}
3832

0 commit comments

Comments
 (0)