Skip to content

Commit

Permalink
fix: Mark ReactTestRendererAsync as internal
Browse files Browse the repository at this point in the history
  • Loading branch information
eps1lon committed Mar 29, 2020
1 parent 8a7bcd5 commit e508cee
Showing 1 changed file with 10 additions and 61 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,15 @@
'use strict';

let React;
let ReactFeatureFlags;
let ReactTestRenderer;
let Scheduler;

describe('ReactTestRendererAsync', () => {
beforeEach(() => {
jest.resetModules();
ReactFeatureFlags = require('shared/ReactFeatureFlags');
ReactFeatureFlags.debugRenderPhaseSideEffectsForStrictMode = false;
React = require('react');
ReactTestRenderer = require('react-test-renderer');
Scheduler = require('scheduler');
Expand Down Expand Up @@ -64,19 +67,11 @@ describe('ReactTestRendererAsync', () => {
unstable_isConcurrent: true,
});

expect(Scheduler).toFlushAndYield(
__DEV__
? ['A:1', 'A:1', 'B:1', 'B:1', 'C:1', 'C:1']
: ['A:1', 'B:1', 'C:1'],
);
expect(Scheduler).toFlushAndYield(['A:1', 'B:1', 'C:1']);
expect(renderer.toJSON()).toEqual(['A:1', 'B:1', 'C:1']);

renderer.update(<Parent step={2} />);
expect(Scheduler).toFlushAndYield(
__DEV__
? ['A:2', 'A:2', 'B:2', 'B:2', 'C:2', 'C:2']
: ['A:2', 'B:2', 'C:2'],
);
expect(Scheduler).toFlushAndYield(['A:2', 'B:2', 'C:2']);
expect(renderer.toJSON()).toEqual(['A:2', 'B:2', 'C:2']);
});

Expand All @@ -99,14 +94,12 @@ describe('ReactTestRendererAsync', () => {
});

// Flush the first two siblings
expect(Scheduler).toFlushAndYieldThrough(
__DEV__ ? ['A:1', 'A:1', 'B:1', 'B:1'] : ['A:1', 'B:1'],
);
expect(Scheduler).toFlushAndYieldThrough(['A:1', 'B:1']);
// Did not commit yet.
expect(renderer.toJSON()).toEqual(null);

// Flush the remaining work
expect(Scheduler).toFlushAndYield(__DEV__ ? ['C:1', 'C:1'] : ['C:1']);
expect(Scheduler).toFlushAndYield(['C:1']);
expect(renderer.toJSON()).toEqual(['A:1', 'B:1', 'C:1']);
});

Expand Down Expand Up @@ -138,9 +131,7 @@ describe('ReactTestRendererAsync', () => {
});

// Flush the some of the changes, but don't commit
expect(Scheduler).toFlushAndYieldThrough(
__DEV__ ? ['A:1', 'A:1'] : ['A:1'],
);
expect(Scheduler).toFlushAndYieldThrough(['A:1']);
expect(renderer.toJSON()).toEqual(null);

// Interrupt with higher priority properties
Expand Down Expand Up @@ -236,54 +227,12 @@ describe('ReactTestRendererAsync', () => {
});

expect(Scheduler).toFlushAndThrow('Oh no!');
expect(Scheduler).toHaveYielded(
__DEV__
? [
'A',
'A',
'B',
'B',
'C',
'C',
'D',
'D',
'A',
'A',
'B',
'B',
'C',
'C',
'D',
'D',
]
: ['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D'],
);
expect(Scheduler).toHaveYielded(['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D']);

renderer.update(<App />);

expect(Scheduler).toFlushAndThrow('Oh no!');
expect(Scheduler).toHaveYielded(
__DEV__
? [
'A',
'A',
'B',
'B',
'C',
'C',
'D',
'D',
'A',
'A',
'B',
'B',
'C',
'C',
'D',
'D',
]
: ['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D'],
);
expect(Scheduler).toHaveYielded(['A', 'B', 'C', 'D', 'A', 'B', 'C', 'D']);

renderer.update(<App />);
expect(Scheduler).toFlushAndThrow('Oh no!');
Expand Down

0 comments on commit e508cee

Please sign in to comment.