Skip to content

Commit ada2b1b

Browse files
phateddanez
authored andcommitted
Add importer tests for setPropDescription
1 parent 7a0916c commit ada2b1b

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

src/utils/__tests__/setPropDescription-test.js

Lines changed: 35 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,12 @@
88

99
jest.mock('../../Documentation');
1010

11-
import { expression } from '../../../tests/utils';
11+
import {
12+
expression,
13+
statement,
14+
noopImporter,
15+
makeMockImporter,
16+
} from '../../../tests/utils';
1217

1318
describe('setPropDescription', () => {
1419
let defaultDocumentation;
@@ -19,10 +24,16 @@ describe('setPropDescription', () => {
1924
setPropDescription = require('../setPropDescription').default;
2025
});
2126

27+
const mockImporter = makeMockImporter({
28+
foo: statement(`
29+
export default 'foo';
30+
`).get('declaration'),
31+
});
32+
2233
function getDescriptors(src, documentation = defaultDocumentation) {
2334
const node = expression(src).get('properties', 0);
2435

25-
setPropDescription(documentation, node);
36+
setPropDescription(documentation, node, noopImporter);
2637

2738
return documentation.descriptors;
2839
}
@@ -72,4 +83,26 @@ describe('setPropDescription', () => {
7283
},
7384
});
7485
});
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+
});
75108
});

0 commit comments

Comments
 (0)