Skip to content

Commit

Permalink
test: add jsx test case
Browse files Browse the repository at this point in the history
  • Loading branch information
sxzz committed Sep 25, 2023
1 parent 0654b73 commit 30bc3b3
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,10 @@ defineComponent((props: {
}
});"
`;
exports[`resolve type > w/ tsx 1`] = `
"import { type SetupContext, defineComponent } from 'vue';
const Comp = defineComponent(() => {
return () => <div />;
}, {});"
`;
16 changes: 15 additions & 1 deletion packages/babel-plugin-resolve-type/test/resolve-type.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@ import { transformAsync } from '@babel/core';
import ResolveType from '../src';

async function transform(code: string): Promise<string> {
const result = await transformAsync(code, { plugins: [ResolveType] });
const result = await transformAsync(code, {
plugins: [[ResolveType, { isTSX: true }]],
});
return result!.code!;
}

Expand Down Expand Up @@ -72,4 +74,16 @@ describe('resolve type', () => {
expect(result).toMatchSnapshot();
});
});

test('w/ tsx', async () => {
const result = await transform(
`
import { type SetupContext, defineComponent } from 'vue';
const Comp = defineComponent(() => {
return () => <div/ >;
});
`
);
expect(result).toMatchSnapshot();
});
});

0 comments on commit 30bc3b3

Please sign in to comment.