1
- import getExportedFunctionBody from '../lib/utils/getExportedFunctionBody /getExportedFunctionBody.utils.js' ;
1
+ import getExportedFunctionBody from './getExportedFunctionBody.utils.js' ;
2
2
3
3
describe ( 'getExportedFunctionBody' , ( ) => {
4
4
it ( 'should extract the body from a default exported function declaration' , ( ) => {
@@ -12,7 +12,9 @@ describe('getExportedFunctionBody', () => {
12
12
return 'Hello, world!';
13
13
` ;
14
14
15
- expect ( getExportedFunctionBody ( inputCode ) ) . toBe ( expectedOutput ) ;
15
+ expect ( getExportedFunctionBody ( inputCode ) . replace ( / \s / g, '' ) ) . toBe (
16
+ expectedOutput . replace ( / \s / g, '' ) ,
17
+ ) ;
16
18
} ) ;
17
19
18
20
it ( 'should extract the body from a default exported anonymous function' , ( ) => {
@@ -26,7 +28,9 @@ describe('getExportedFunctionBody', () => {
26
28
return 'Hello, world!';
27
29
` ;
28
30
29
- expect ( getExportedFunctionBody ( inputCode ) ) . toBe ( expectedOutput ) ;
31
+ expect ( getExportedFunctionBody ( inputCode ) . replace ( / \s / g, '' ) ) . toBe (
32
+ expectedOutput . replace ( / \s / g, '' ) ,
33
+ ) ;
30
34
} ) ;
31
35
32
36
it ( 'should extract the body from a default exported arrow function' , ( ) => {
@@ -40,7 +44,9 @@ describe('getExportedFunctionBody', () => {
40
44
return 'Hello, world!';
41
45
` ;
42
46
43
- expect ( getExportedFunctionBody ( inputCode ) ) . toBe ( expectedOutput ) ;
47
+ expect ( getExportedFunctionBody ( inputCode ) . replace ( / \s / g, '' ) ) . toBe (
48
+ expectedOutput . replace ( / \s / g, '' ) ,
49
+ ) ;
44
50
} ) ;
45
51
46
52
it ( 'should extract the body from a default exported function assigned to a variable' , ( ) => {
@@ -55,7 +61,9 @@ describe('getExportedFunctionBody', () => {
55
61
return 'Hello, world!';
56
62
` ;
57
63
58
- expect ( getExportedFunctionBody ( inputCode ) ) . toBe ( expectedOutput ) ;
64
+ expect ( getExportedFunctionBody ( inputCode ) . replace ( / \s / g, '' ) ) . toBe (
65
+ expectedOutput . replace ( / \s / g, '' ) ,
66
+ ) ;
59
67
} ) ;
60
68
61
69
it ( 'should throw an error if there are no default exports' , ( ) => {
@@ -65,6 +73,8 @@ describe('getExportedFunctionBody', () => {
65
73
}
66
74
` ;
67
75
68
- expect ( ( ) => getExportedFunctionBody ( inputCode ) ) . toThrow ( 'No default exports were found for entrypoint in the provided code.' ) ;
76
+ expect ( ( ) => getExportedFunctionBody ( inputCode ) ) . toThrow (
77
+ 'No default exports were found for entrypoint in the provided code.' ,
78
+ ) ;
69
79
} ) ;
70
- } ) ;
80
+ } ) ;
0 commit comments