Use renderToStaticMarkup for tests (#16516)
Gerald Monaco committed
Aug 29, 2019 at 08:08 UTC
f61138e0681f729c43cf755f48f060e6262a09eb
1 file changed
+10
-10
packages/react-dom/src/__tests__/ReactServerRendering-test.js
+10
-10
@@ -320,7 +320,7 @@ describe('ReactDOMServer', () => {
320
return <div>{this.state.text}</div>;
321
}
322
}
323
- const markup = ReactDOMServer.renderToString(<Component />);
323
+ const markup = ReactDOMServer.renderToStaticMarkup(<Component />);
324
expect(markup).toContain('hello, world');
325
});
326
@@ -339,7 +339,7 @@ describe('ReactDOMServer', () => {
339
return <div>{this.state.text}</div>;
340
}
341
}
342
- const markup = ReactDOMServer.renderToString(<Component />);
342
+ const markup = ReactDOMServer.renderToStaticMarkup(<Component />);
343
expect(markup).toContain('hello, world');
344
});
345
@@ -354,7 +354,7 @@ describe('ReactDOMServer', () => {
354
}
355
}
356
357
- const markup = ReactDOMServer.renderToString(
357
+ const markup = ReactDOMServer.renderToStaticMarkup(
358
<Component text="hello, world" />,
359
);
360
expect(markup).toContain('hello, world');
@@ -391,7 +391,7 @@ describe('ReactDOMServer', () => {
391
text: PropTypes.string,
392
};
393
394
- const markup = ReactDOMServer.renderToString(
394
+ const markup = ReactDOMServer.renderToStaticMarkup(
395
<ContextProvider>
396
<Component />
397
</ContextProvider>,
@@ -429,7 +429,7 @@ describe('ReactDOMServer', () => {
429
);
430
}
431
432
- const markup = ReactDOMServer.renderToString(<App value={1} />);
432
+ const markup = ReactDOMServer.renderToStaticMarkup(<App value={1} />);
433
// Extract the numbers rendered by the consumers
434
const results = markup.match(/\d+/g).map(Number);
435
expect(results).toEqual([2, 1, 3, 1]);
@@ -467,7 +467,7 @@ describe('ReactDOMServer', () => {
467
);
468
}
469
470
- const markup = ReactDOMServer.renderToString(<App value={1} />);
470
+ const markup = ReactDOMServer.renderToStaticMarkup(<App value={1} />);
471
// Extract the numbers rendered by the consumers
472
const results = markup.match(/\d+/g).map(Number);
473
expect(results).toEqual([2, 1, 3, 1]);
@@ -484,7 +484,7 @@ describe('ReactDOMServer', () => {
484
485
let reentrantMarkup;
486
function Reentrant() {
487
- reentrantMarkup = ReactDOMServer.renderToString(
487
+ reentrantMarkup = ReactDOMServer.renderToStaticMarkup(
488
<App value={1} reentrant={false} />,
489
);
490
return null;
@@ -512,7 +512,7 @@ describe('ReactDOMServer', () => {
512
);
513
}
514
515
- const markup = ReactDOMServer.renderToString(
515
+ const markup = ReactDOMServer.renderToStaticMarkup(
516
<App value={1} reentrant={true} />,
517
);
518
// Extract the numbers rendered by the consumers
@@ -566,7 +566,7 @@ describe('ReactDOMServer', () => {
566
},
567
}));
568
569
- expect(ReactDOMServer.renderToString(<LazyFoo id="foo" />)).toEqual(
569
+ expect(ReactDOMServer.renderToStaticMarkup(<LazyFoo id="foo" />)).toEqual(
570
'<div id="foo">lazy</div>',
571
);
572
});
@@ -578,7 +578,7 @@ describe('ReactDOMServer', () => {
578
},
579
}));
580
581
- expect(() => ReactDOMServer.renderToString(<LazyFoo />)).toThrow(
581
+ expect(() => ReactDOMServer.renderToStaticMarkup(<LazyFoo />)).toThrow(
582
'Bad lazy',
583
);
584
});