@@ -12,36 +12,38 @@ function hello() {
1212
1313describe ( 'formatFunction' , ( ) => {
1414 it ( 'should replace a function with noRefCheck without showFunctions option' , ( ) => {
15- expect ( formatFunction ( hello , { } ) ) . toEqual ( 'function noRefCheck() {}' ) ;
15+ expect ( formatFunction ( hello , true , 0 , { } ) ) . toEqual (
16+ 'function noRefCheck() {}'
17+ ) ;
1618 } ) ;
1719
1820 it ( 'should replace a function with noRefCheck if showFunctions is false' , ( ) => {
19- expect ( formatFunction ( hello , { showFunctions : false } ) ) . toEqual (
21+ expect ( formatFunction ( hello , true , 0 , { showFunctions : false } ) ) . toEqual (
2022 'function noRefCheck() {}'
2123 ) ;
2224 } ) ;
2325
2426 it ( 'should format a function if showFunctions is true' , ( ) => {
25- expect ( formatFunction ( hello , { showFunctions : true } ) ) . toEqual (
27+ expect ( formatFunction ( hello , true , 0 , { showFunctions : true } ) ) . toEqual (
2628 'function hello() {return 1;}'
2729 ) ;
2830 } ) ;
2931
3032 it ( 'should format a function without name if showFunctions is true' , ( ) => {
31- expect ( formatFunction ( ( ) => 1 , { showFunctions : true } ) ) . toEqual (
33+ expect ( formatFunction ( ( ) => 1 , true , 0 , { showFunctions : true } ) ) . toEqual (
3234 'function () {return 1;}'
3335 ) ;
3436 } ) ;
3537
3638 it ( 'should use the functionValue option' , ( ) => {
37- expect ( formatFunction ( hello , { functionValue : ( ) => '<Test />' } ) ) . toEqual (
38- '<Test />'
39- ) ;
39+ expect (
40+ formatFunction ( hello , true , 0 , { functionValue : ( ) => '<Test />' } )
41+ ) . toEqual ( '<Test />' ) ;
4042 } ) ;
4143
4244 it ( 'should use the functionValue option even if showFunctions is true' , ( ) => {
4345 expect (
44- formatFunction ( hello , {
46+ formatFunction ( hello , true , 0 , {
4547 showFunctions : true ,
4648 functionValue : ( ) => '<Test />' ,
4749 } )
@@ -50,10 +52,22 @@ describe('formatFunction', () => {
5052
5153 it ( 'should use the functionValue option even if showFunctions is false' , ( ) => {
5254 expect (
53- formatFunction ( hello , {
55+ formatFunction ( hello , true , 0 , {
5456 showFunctions : false ,
5557 functionValue : ( ) => '<Test />' ,
5658 } )
5759 ) . toEqual ( '<Test />' ) ;
5860 } ) ;
61+
62+ it ( 'should format multi-line function' , ( ) => {
63+ expect (
64+ formatFunction ( hello , false , 0 , { showFunctions : true , tabStop : 2 } )
65+ ) . toEqual ( 'function hello() {\n return 1;\n}' ) ;
66+ } ) ;
67+
68+ it ( 'should format multi-line function with indentation' , ( ) => {
69+ expect (
70+ formatFunction ( hello , false , 1 , { showFunctions : true , tabStop : 2 } )
71+ ) . toEqual ( 'function hello() {\n return 1;\n }' ) ;
72+ } ) ;
5973} ) ;
0 commit comments