@@ -151,6 +151,21 @@ describe('componentDocblockHandler', () => {
151
151
) ;
152
152
} ) ;
153
153
154
+ describe ( 'Stateless functions' , ( ) => {
155
+ test (
156
+ 'function Component() {}' ,
157
+ src => lastStatement ( src )
158
+ ) ;
159
+ test (
160
+ 'var Component = function () {};' ,
161
+ src => lastStatement ( src ) . get ( 'declarations' , 0 , 'init' )
162
+ ) ;
163
+ test (
164
+ 'var Component = () => {}' ,
165
+ src => lastStatement ( src ) . get ( 'declarations' , 0 , 'init' )
166
+ ) ;
167
+ } ) ;
168
+
154
169
describe ( 'ES6 default exports' , ( ) => {
155
170
156
171
describe ( 'Default React.createClass export' , ( ) => {
@@ -182,6 +197,31 @@ describe('componentDocblockHandler', () => {
182
197
) ;
183
198
} ) ;
184
199
200
+ describe ( 'Default stateless function export' , ( ) => {
201
+
202
+ describe ( 'named function' , ( ) => {
203
+ test (
204
+ 'export default function Component() {}' ,
205
+ src => lastStatement ( src ) . get ( 'declaration' )
206
+ ) ;
207
+ } ) ;
208
+
209
+ describe ( 'anonymous function' , ( ) => {
210
+ test (
211
+ 'export default function() {}' ,
212
+ src => lastStatement ( src ) . get ( 'declaration' )
213
+ ) ;
214
+ } ) ;
215
+
216
+ describe ( 'arrow function' , ( ) => {
217
+ test (
218
+ 'export default () => {}' ,
219
+ src => lastStatement ( src ) . get ( 'declaration' )
220
+ ) ;
221
+ } ) ;
222
+
223
+ } ) ;
224
+
185
225
} ) ;
186
226
187
227
describe ( 'ES6 named exports' , ( ) => {
@@ -206,5 +246,30 @@ describe('componentDocblockHandler', () => {
206
246
) ;
207
247
} ) ;
208
248
249
+ describe ( 'Named stateless function' , ( ) => {
250
+
251
+ describe ( 'named function' , ( ) => {
252
+ test (
253
+ 'export function Component() {}' ,
254
+ src => lastStatement ( src ) . get ( 'declaration' )
255
+ ) ;
256
+ } ) ;
257
+
258
+ describe ( 'anonymous function' , ( ) => {
259
+ test (
260
+ 'export var Component = function() {}' ,
261
+ src => lastStatement ( src ) . get ( 'declaration' )
262
+ ) ;
263
+ } ) ;
264
+
265
+ describe ( 'arrow function' , ( ) => {
266
+ test (
267
+ 'export var Component = () => {}' ,
268
+ src => lastStatement ( src ) . get ( 'declaration' )
269
+ ) ;
270
+ } ) ;
271
+
272
+ } ) ;
273
+
209
274
} ) ;
210
275
} ) ;
0 commit comments