@samitouri / QOS-React-2 / commits / 97b7d0eff5

Test top-level callback when re-rendering with same element

Andrew Clark committed Dec 8, 2016 at 09:36 UTC 97b7d0eff5e25ab9efd6f17e9a51dd378a725f54
2 files changed +30
scripts/fiber/tests-passing.txt
+1
@@ -505,6 +505,7 @@ src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js
505 * should render strings as children
506 * should render numbers as children
507 * should be called a callback argument
508 +* should call a callback argument when the same element is re-rendered
509 * should render a component returning strings directly from render
510 * should render a component returning numbers directly from render
511 * finds the DOM Text node of a string child
src/renderers/dom/fiber/__tests__/ReactDOMFiber-test.js
+29
@@ -64,6 +64,35 @@ describe('ReactDOMFiber', () => {
64 expect(called).toEqual(true);
65 });
66
67 + it('should call a callback argument when the same element is re-rendered', () => {
68 + class Foo extends React.Component {
69 + render() {
70 + return <div>Foo</div>;
71 + }
72 + }
73 + const element = <Foo />;
74 +
75 + // mounting phase
76 + let called = false;
77 + ReactDOM.render(
78 + element,
79 + container,
80 + () => called = true
81 + );
82 + expect(called).toEqual(true);
83 +
84 + // updating phase
85 + called = false;
86 + ReactDOM.unstable_batchedUpdates(() => {
87 + ReactDOM.render(
88 + element,
89 + container,
90 + () => called = true
91 + );
92 + });
93 + expect(called).toEqual(true);
94 + });
95 +
96 if (ReactDOMFeatureFlags.useFiber) {
97 it('should render a component returning strings directly from render', () => {
98 const Text = ({value}) => value;