@@ -56,21 +56,25 @@ describe('main', () => {
56
56
test ( `
57
57
var React = require("React");
58
58
var PropTypes = React.PropTypes;
59
+
60
+ var defaultProps = {
61
+ foo: true,
62
+ };
63
+ var propTypes = {
64
+ /**
65
+ * Example prop description
66
+ */
67
+ foo: PropTypes.bool
68
+ };
69
+
59
70
/**
60
71
* Example component description
61
72
*/
62
73
var Component = React.createClass({
63
74
displayName: 'ABC',
64
- propTypes: {
65
- /**
66
- * Example prop description
67
- */
68
- foo: PropTypes.bool
69
- },
75
+ propTypes,
70
76
getDefaultProps: function() {
71
- return {
72
- foo: true
73
- };
77
+ return defaultProps;
74
78
}
75
79
});
76
80
module.exports = Component
@@ -79,23 +83,27 @@ describe('main', () => {
79
83
80
84
describe ( 'Class definition' , ( ) => {
81
85
test ( `
82
- var React = require("React");
83
- var PropTypes = React.PropTypes;
86
+ const React = require("React");
87
+ const PropTypes = React.PropTypes;
88
+
89
+ const defaultProps = {
90
+ foo: true,
91
+ };
92
+ const propTypes = {
93
+ /**
94
+ * Example prop description
95
+ */
96
+ foo: PropTypes.bool
97
+ };
98
+
84
99
/**
85
100
* Example component description
86
101
*/
87
102
export default class Component extends React.Component {
88
- static propTypes = {
89
- /**
90
- * Example prop description
91
- */
92
- foo: PropTypes.bool
93
- };
103
+ static propTypes = propTypes;
94
104
// ...
95
105
}
96
- Component.defaultProps = {
97
- foo: true,
98
- };
106
+ Component.defaultProps = defaultProps;
99
107
Component.displayName = 'ABC';
100
108
` ) ;
101
109
} ) ;
@@ -104,21 +112,23 @@ describe('main', () => {
104
112
test ( `
105
113
import React, {PropTypes} from "React";
106
114
115
+ const defaultProps = {
116
+ foo: true,
117
+ };
118
+ const propTypes = {
119
+ /**
120
+ * Example prop description
121
+ */
122
+ foo: PropTypes.bool
123
+ };
124
+
107
125
/**
108
126
* Example component description
109
127
*/
110
128
let Component = props => <div />;
111
129
Component.displayName = 'ABC';
112
- Component.defaultProps = {
113
- foo: true
114
- };
115
-
116
- Component.propTypes = {
117
- /**
118
- * Example prop description
119
- */
120
- foo: PropTypes.bool
121
- };
130
+ Component.defaultProps = defaultProps;
131
+ Component.propTypes = propTypes;
122
132
123
133
export default Component;
124
134
` ) ;
@@ -128,6 +138,16 @@ describe('main', () => {
128
138
test ( `
129
139
import React, {PropTypes} from "React";
130
140
141
+ const defaultProps = {
142
+ foo: true,
143
+ };
144
+ const propTypes = {
145
+ /**
146
+ * Example prop description
147
+ */
148
+ foo: PropTypes.bool
149
+ };
150
+
131
151
/**
132
152
* Example component description
133
153
*/
@@ -136,16 +156,8 @@ describe('main', () => {
136
156
}
137
157
138
158
Component.displayName = 'ABC';
139
- Component.defaultProps = {
140
- foo: true
141
- };
142
-
143
- Component.propTypes = {
144
- /**
145
- * Example prop description
146
- */
147
- foo: PropTypes.bool
148
- };
159
+ Component.defaultProps = defaultProps;
160
+ Component.propTypes = propTypes;
149
161
150
162
export default Component;
151
163
` ) ;
@@ -155,6 +167,16 @@ describe('main', () => {
155
167
test ( `
156
168
import React, {PropTypes} from "React";
157
169
170
+ const defaultProps = {
171
+ foo: true,
172
+ };
173
+ const propTypes = {
174
+ /**
175
+ * Example prop description
176
+ */
177
+ foo: PropTypes.bool
178
+ };
179
+
158
180
/**
159
181
* Example component description
160
182
*/
@@ -163,16 +185,8 @@ describe('main', () => {
163
185
}
164
186
165
187
Component.displayName = 'ABC';
166
- Component.defaultProps = {
167
- foo: true
168
- };
169
-
170
- Component.propTypes = {
171
- /**
172
- * Example prop description
173
- */
174
- foo: PropTypes.bool
175
- };
188
+ Component.defaultProps = defaultProps;
189
+ Component.propTypes = propTypes;
176
190
177
191
export default Component;
178
192
` ) ;
0 commit comments