Skip to content

Commit 44c74c7

Browse files
authored
Add smoke tests for styles (including SSR) (#10308)
* Add style to ReactDOM smoke test * Add production smoke test for ReactDOMServer
1 parent 69d0761 commit 44c74c7

File tree

1 file changed

+30
-2
lines changed

1 file changed

+30
-2
lines changed

src/renderers/dom/__tests__/ReactDOMProduction-test.js

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ describe('ReactDOMProduction', () => {
1515

1616
var React;
1717
var ReactDOM;
18+
var ReactDOMServer;
1819
var oldProcess;
1920

2021
beforeEach(() => {
@@ -31,6 +32,7 @@ describe('ReactDOMProduction', () => {
3132
jest.resetModules();
3233
React = require('react');
3334
ReactDOM = require('react-dom');
35+
ReactDOMServer = require('react-dom/server');
3436
});
3537

3638
afterEach(() => {
@@ -64,7 +66,7 @@ describe('ReactDOMProduction', () => {
6466

6567
var container = document.createElement('div');
6668
var inst = ReactDOM.render(
67-
<div className="blue">
69+
<div className="blue" style={{fontFamily: 'Helvetica'}}>
6870
<Component key={1}>A</Component>
6971
<Component key={2}>B</Component>
7072
<Component key={3}>C</Component>
@@ -74,10 +76,11 @@ describe('ReactDOMProduction', () => {
7476

7577
expect(container.firstChild).toBe(inst);
7678
expect(inst.className).toBe('blue');
79+
expect(inst.style.fontFamily).toBe('Helvetica');
7780
expect(inst.textContent).toBe('ABC');
7881

7982
ReactDOM.render(
80-
<div className="red">
83+
<div className="red" style={{fontFamily: 'Comic Sans MS'}}>
8184
<Component key={2}>B</Component>
8285
<Component key={1}>A</Component>
8386
<Component key={3}>C</Component>
@@ -86,13 +89,38 @@ describe('ReactDOMProduction', () => {
8689
);
8790

8891
expect(inst.className).toBe('red');
92+
expect(inst.style.fontFamily).toBe('Comic Sans MS');
8993
expect(inst.textContent).toBe('BAC');
9094

9195
ReactDOM.unmountComponentAtNode(container);
9296

9397
expect(container.childNodes.length).toBe(0);
9498
});
9599

100+
it('should handle a simple flow (ssr)', () => {
101+
class Component extends React.Component {
102+
render() {
103+
return <span>{this.props.children}</span>;
104+
}
105+
}
106+
107+
var container = document.createElement('div');
108+
var markup = ReactDOMServer.renderToString(
109+
<div className="blue" style={{fontFamily: 'Helvetica'}}>
110+
<Component key={1}>A</Component>
111+
<Component key={2}>B</Component>
112+
<Component key={3}>C</Component>
113+
</div>,
114+
container,
115+
);
116+
container.innerHTML = markup;
117+
var inst = container.firstChild;
118+
119+
expect(inst.className).toBe('blue');
120+
expect(inst.style.fontFamily).toBe('Helvetica');
121+
expect(inst.textContent).toBe('ABC');
122+
});
123+
96124
it('should call lifecycle methods', () => {
97125
var log = [];
98126
class Component extends React.Component {

0 commit comments

Comments
 (0)