Skip to content

Commit

Permalink
chore: fix oom
Browse files Browse the repository at this point in the history
  • Loading branch information
ymqy committed Jan 27, 2023
1 parent b053f41 commit 4d6d480
Showing 1 changed file with 23 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,18 @@ describe('ReactSuspenseWithNoopRenderer', () => {
);
}

function removeNonEnumerableProperties(input) {
if (Array.isArray(input)) {
input = input.map(item => removeNonEnumerableProperties(item));
} else if (typeof input === 'object') {
input = Object.keys(input).reduce((obj, key) => {
obj[key] = removeNonEnumerableProperties(input[key]);
return obj;
}, {});
}
return input;
}

// @gate enableLegacyCache
it('does not restart rendering for initial render', async () => {
function Bar(props) {
Expand Down Expand Up @@ -2428,17 +2440,21 @@ describe('ReactSuspenseWithNoopRenderer', () => {
'Loading B...',
]);
// Still suspended.
expect(ReactNoop.getChildren()).toEqual([span('A')]);
expect(removeNonEnumerableProperties(ReactNoop.getChildren())).toEqual([
span('A'),
]);

// Flush to skip suspended time.
Scheduler.unstable_advanceTime(600);
await advanceTimers(600);

if (gate(flags => flags.enableSyncDefaultUpdates)) {
// Transitions never fall back.
expect(ReactNoop.getChildren()).toEqual([span('A')]);
expect(removeNonEnumerableProperties(ReactNoop.getChildren())).toEqual([
span('A'),
]);
} else {
expect(ReactNoop.getChildren()).toEqual([
expect(removeNonEnumerableProperties(ReactNoop.getChildren())).toEqual([
span('A'),
span('Loading B...'),
]);
Expand Down Expand Up @@ -2954,7 +2970,10 @@ describe('ReactSuspenseWithNoopRenderer', () => {
expect(Scheduler).toFlushAndYield(['Hi!', 'Suspend! [B]', 'Loading B...']);

// Suspended
expect(ReactNoop.getChildren()).toEqual([span('Hi!'), span('A')]);
expect(removeNonEnumerableProperties(ReactNoop.getChildren())).toEqual([
span('Hi!'),
span('A'),
]);
Scheduler.unstable_advanceTime(1800);
await advanceTimers(1800);
expect(Scheduler).toFlushAndYield([]);
Expand Down

0 comments on commit 4d6d480

Please sign in to comment.