File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change 2
2
var assert = require ( 'simple-assert' ) ;
3
3
var getFuncName = require ( '..' ) ;
4
4
describe ( 'getFuncName' , function ( ) {
5
- it ( 'getFuncName' , function ( ) {
6
- // Asserting that `getFuncName` behaves correctly
5
+ it ( 'should get the function name' , function ( ) {
6
+ function normalFunction ( ) {
7
+ return 1 ;
8
+ }
9
+
10
+ assert ( getFuncName ( normalFunction ) === 'normalFunction' ) ;
11
+ } ) ;
12
+
13
+ it ( 'should get correct name when function is surrounded by comments' , function ( ) {
7
14
function /*one*/ correctName /*two*/ ( ) { // eslint-disable-line no-inline-comments, spaced-comment
8
15
return 0 ;
9
16
}
10
- function withoutComments ( ) {
11
- return 1 ;
12
- }
13
17
18
+ assert ( getFuncName ( correctName ) === 'correctName' ) ;
19
+ } ) ;
20
+
21
+ it ( 'should return empty string for anonymous functions' , function ( ) {
14
22
var anonymousFunc = ( function ( ) {
15
23
return function ( ) { // eslint-disable-line func-style
16
24
return 2 ;
17
25
} ;
18
26
} ( ) ) ;
19
- assert ( getFuncName ( correctName ) === 'correctName' ) ;
20
- assert ( getFuncName ( withoutComments ) === 'withoutComments' ) ;
21
27
assert ( getFuncName ( anonymousFunc ) === '' ) ;
22
28
} ) ;
23
29
} ) ;
30
+
You can’t perform that action at this time.
0 commit comments