8
8
9
9
jest . mock ( '../../Documentation' ) ;
10
10
11
- import { expression } from '../../../tests/utils' ;
11
+ import {
12
+ expression ,
13
+ statement ,
14
+ noopImporter ,
15
+ makeMockImporter ,
16
+ } from '../../../tests/utils' ;
12
17
13
18
describe ( 'setPropDescription' , ( ) => {
14
19
let defaultDocumentation ;
@@ -19,10 +24,16 @@ describe('setPropDescription', () => {
19
24
setPropDescription = require ( '../setPropDescription' ) . default ;
20
25
} ) ;
21
26
27
+ const mockImporter = makeMockImporter ( {
28
+ foo : statement ( `
29
+ export default 'foo';
30
+ ` ) . get ( 'declaration' ) ,
31
+ } ) ;
32
+
22
33
function getDescriptors ( src , documentation = defaultDocumentation ) {
23
34
const node = expression ( src ) . get ( 'properties' , 0 ) ;
24
35
25
- setPropDescription ( documentation , node ) ;
36
+ setPropDescription ( documentation , node , noopImporter ) ;
26
37
27
38
return documentation . descriptors ;
28
39
}
@@ -72,4 +83,26 @@ describe('setPropDescription', () => {
72
83
} ,
73
84
} ) ;
74
85
} ) ;
86
+
87
+ it ( 'resolves computed props to imported values' , ( ) => {
88
+ const src = `
89
+ ({
90
+ /**
91
+ * my description 3
92
+ */
93
+
94
+ [a]: boolean,
95
+ });
96
+ import a from 'foo';
97
+ ` ;
98
+ const node = statement ( src ) . get ( 'expression' , 'properties' , 0 ) ;
99
+
100
+ setPropDescription ( defaultDocumentation , node , mockImporter ) ;
101
+
102
+ expect ( defaultDocumentation . descriptors ) . toEqual ( {
103
+ foo : {
104
+ description : 'my description 3' ,
105
+ } ,
106
+ } ) ;
107
+ } ) ;
75
108
} ) ;
0 commit comments