mirror of
https://github.com/zebrajr/react.git
synced 2026-01-15 12:15:22 +00:00
Configure react-test-renderer as a secondary (#13164)
This commit is contained in:
@@ -28,6 +28,10 @@ const Circle = require('react-art/Circle');
|
||||
const Rectangle = require('react-art/Rectangle');
|
||||
const Wedge = require('react-art/Wedge');
|
||||
|
||||
// Isolate the noop renderer
|
||||
jest.resetModules();
|
||||
const ReactNoop = require('react-noop-renderer');
|
||||
|
||||
let Group;
|
||||
let Shape;
|
||||
let Surface;
|
||||
@@ -354,7 +358,7 @@ describe('ReactART', () => {
|
||||
const CurrentRendererContext = React.createContext(null);
|
||||
|
||||
function Yield(props) {
|
||||
testRenderer.unstable_yield(props.value);
|
||||
ReactNoop.yield(props.value);
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -372,19 +376,16 @@ describe('ReactART', () => {
|
||||
|
||||
// Using test renderer instead of the DOM renderer here because async
|
||||
// testing APIs for the DOM renderer don't exist.
|
||||
const testRenderer = ReactTestRenderer.create(
|
||||
ReactNoop.render(
|
||||
<CurrentRendererContext.Provider value="Test">
|
||||
<Yield value="A" />
|
||||
<Yield value="B" />
|
||||
<LogCurrentRenderer />
|
||||
<Yield value="C" />
|
||||
</CurrentRendererContext.Provider>,
|
||||
{
|
||||
unstable_isAsync: true,
|
||||
},
|
||||
);
|
||||
|
||||
testRenderer.unstable_flushThrough(['A']);
|
||||
ReactNoop.flushThrough(['A']);
|
||||
|
||||
ReactDOM.render(
|
||||
<Surface>
|
||||
@@ -399,7 +400,7 @@ describe('ReactART', () => {
|
||||
expect(ops).toEqual([null, 'ART']);
|
||||
|
||||
ops = [];
|
||||
expect(testRenderer.unstable_flushAll()).toEqual(['B', 'C']);
|
||||
expect(ReactNoop.flush()).toEqual(['B', 'C']);
|
||||
|
||||
expect(ops).toEqual(['Test']);
|
||||
});
|
||||
|
||||
@@ -180,7 +180,7 @@ export function createTextInstance(
|
||||
};
|
||||
}
|
||||
|
||||
export const isPrimaryRenderer = true;
|
||||
export const isPrimaryRenderer = false;
|
||||
// This approach enables `now` to be mocked by tests,
|
||||
// Even after the reconciler has initialized and read host config values.
|
||||
export const now = () => TestRendererScheduling.nowImplementation();
|
||||
|
||||
@@ -16,6 +16,10 @@ const React = require('react');
|
||||
const ReactTestRenderer = require('react-test-renderer');
|
||||
const prettyFormat = require('pretty-format');
|
||||
|
||||
// Isolate noop renderer
|
||||
jest.resetModules();
|
||||
const ReactNoop = require('react-noop-renderer');
|
||||
|
||||
// Kind of hacky, but we nullify all the instances to test the tree structure
|
||||
// with jasmine's deep equality function, and test the instances separate. We
|
||||
// also delete children props because testing them is more annoying and not
|
||||
@@ -1000,4 +1004,19 @@ describe('ReactTestRenderer', () => {
|
||||
}),
|
||||
);
|
||||
});
|
||||
|
||||
it('can concurrently render context with a "primary" renderer', () => {
|
||||
const Context = React.createContext(null);
|
||||
const Indirection = React.Fragment;
|
||||
const App = () => (
|
||||
<Context.Provider>
|
||||
<Indirection>
|
||||
<Context.Consumer>{() => null}</Context.Consumer>
|
||||
</Indirection>
|
||||
</Context.Provider>
|
||||
);
|
||||
ReactNoop.render(<App />);
|
||||
ReactNoop.flush();
|
||||
ReactTestRenderer.create(<App />);
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user