Skip to content

Commit 30bc3b3

Browse files
committed
test: add jsx test case
1 parent 0654b73 commit 30bc3b3

File tree

2 files changed

+22
-1
lines changed

2 files changed

+22
-1
lines changed

packages/babel-plugin-resolve-type/test/__snapshots__/resolve-type.test.tsx.snap

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,3 +80,10 @@ defineComponent((props: {
8080
}
8181
});"
8282
`;
83+
84+
exports[`resolve type > w/ tsx 1`] = `
85+
"import { type SetupContext, defineComponent } from 'vue';
86+
const Comp = defineComponent(() => {
87+
return () => <div />;
88+
}, {});"
89+
`;

packages/babel-plugin-resolve-type/test/resolve-type.test.tsx

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@ import { transformAsync } from '@babel/core';
22
import ResolveType from '../src';
33

44
async function transform(code: string): Promise<string> {
5-
const result = await transformAsync(code, { plugins: [ResolveType] });
5+
const result = await transformAsync(code, {
6+
plugins: [[ResolveType, { isTSX: true }]],
7+
});
68
return result!.code!;
79
}
810

@@ -72,4 +74,16 @@ describe('resolve type', () => {
7274
expect(result).toMatchSnapshot();
7375
});
7476
});
77+
78+
test('w/ tsx', async () => {
79+
const result = await transform(
80+
`
81+
import { type SetupContext, defineComponent } from 'vue';
82+
const Comp = defineComponent(() => {
83+
return () => <div/ >;
84+
});
85+
`
86+
);
87+
expect(result).toMatchSnapshot();
88+
});
7589
});

0 commit comments

Comments
 (0)