test: add jsx test case

This commit is contained in:
三咲智子 Kevin Deng 2023-09-04 16:42:33 +08:00
parent 0654b73e90
commit 30bc3b3afb
No known key found for this signature in database
GPG Key ID: 69992F2250DFD93E
2 changed files with 22 additions and 1 deletions

View File

@ -80,3 +80,10 @@ defineComponent((props: {
} }
});" });"
`; `;
exports[`resolve type > w/ tsx 1`] = `
"import { type SetupContext, defineComponent } from 'vue';
const Comp = defineComponent(() => {
return () => <div />;
}, {});"
`;

View File

@ -2,7 +2,9 @@ import { transformAsync } from '@babel/core';
import ResolveType from '../src'; import ResolveType from '../src';
async function transform(code: string): Promise<string> { 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!; return result!.code!;
} }
@ -72,4 +74,16 @@ describe('resolve type', () => {
expect(result).toMatchSnapshot(); 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();
});
}); });