Skip to content

Commit c501f19

Browse files
phateddanez
authored andcommitted
Add importer tests for isReactCreateElementCall
1 parent 3b628fc commit c501f19

File tree

1 file changed

+21
-1
lines changed

1 file changed

+21
-1
lines changed

src/utils/__tests__/isReactCreateElementCall-test.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,12 @@
66
*
77
*/
88

9-
import { parse, noopImporter } from '../../../tests/utils';
9+
import {
10+
parse,
11+
statement,
12+
noopImporter,
13+
makeMockImporter,
14+
} from '../../../tests/utils';
1015
import isReactCreateElementCall from '../isReactCreateElementCall';
1116

1217
describe('isReactCreateElementCall', () => {
@@ -15,6 +20,13 @@ describe('isReactCreateElementCall', () => {
1520
return root.get('body', root.node.body.length - 1, 'expression');
1621
}
1722

23+
const mockImporter = makeMockImporter({
24+
foo: statement(`
25+
export default React.createElement;
26+
import React from 'react';
27+
`).get('declaration'),
28+
});
29+
1830
describe('built in React.createElement', () => {
1931
it('accepts createElement called on React', () => {
2032
const def = parsePath(`
@@ -85,5 +97,13 @@ describe('isReactCreateElementCall', () => {
8597
`);
8698
expect(isReactCreateElementCall(def, noopImporter)).toBe(true);
8799
});
100+
101+
it('can resolve createElement imported from an intermediate module', () => {
102+
const def = parsePath(`
103+
import foo from "foo";
104+
foo({});
105+
`);
106+
expect(isReactCreateElementCall(def, mockImporter)).toBe(true);
107+
});
88108
});
89109
});

0 commit comments

Comments
 (0)