From 30bc3b3afb0fdce5fd32457571582d94b594517a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=B8=89=E5=92=B2=E6=99=BA=E5=AD=90=20Kevin=20Deng?= Date: Mon, 4 Sep 2023 16:42:33 +0800 Subject: [PATCH] test: add jsx test case --- .../__snapshots__/resolve-type.test.tsx.snap | 7 +++++++ .../test/resolve-type.test.tsx | 16 +++++++++++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/packages/babel-plugin-resolve-type/test/__snapshots__/resolve-type.test.tsx.snap b/packages/babel-plugin-resolve-type/test/__snapshots__/resolve-type.test.tsx.snap index baa55e9..ccf0e45 100644 --- a/packages/babel-plugin-resolve-type/test/__snapshots__/resolve-type.test.tsx.snap +++ b/packages/babel-plugin-resolve-type/test/__snapshots__/resolve-type.test.tsx.snap @@ -80,3 +80,10 @@ defineComponent((props: { } });" `; + +exports[`resolve type > w/ tsx 1`] = ` +"import { type SetupContext, defineComponent } from 'vue'; +const Comp = defineComponent(() => { + return () =>
; +}, {});" +`; diff --git a/packages/babel-plugin-resolve-type/test/resolve-type.test.tsx b/packages/babel-plugin-resolve-type/test/resolve-type.test.tsx index db22e8b..5830de4 100644 --- a/packages/babel-plugin-resolve-type/test/resolve-type.test.tsx +++ b/packages/babel-plugin-resolve-type/test/resolve-type.test.tsx @@ -2,7 +2,9 @@ import { transformAsync } from '@babel/core'; import ResolveType from '../src'; async function transform(code: string): Promise { - const result = await transformAsync(code, { plugins: [ResolveType] }); + const result = await transformAsync(code, { + plugins: [[ResolveType, { isTSX: true }]], + }); return result!.code!; } @@ -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 () =>
; + }); + ` + ); + expect(result).toMatchSnapshot(); + }); });