From 16ca64e19f12721959c6c8ba6b996d209b82ce8c Mon Sep 17 00:00:00 2001 From: Jaw <53564781+jaw52@users.noreply.github.com> Date: Wed, 2 Aug 2023 00:34:10 +0800 Subject: [PATCH] fix: lines break (#156) --- src/core/transform.ts | 2 +- test/transform_filter.test.ts | 75 +++++++++++++++++++++++++++++++++++ 2 files changed, 76 insertions(+), 1 deletion(-) create mode 100644 test/transform_filter.test.ts diff --git a/src/core/transform.ts b/src/core/transform.ts index ad3ad31..06853c5 100644 --- a/src/core/transform.ts +++ b/src/core/transform.ts @@ -6,7 +6,7 @@ import { transformScriptSetup } from './transformScriptSetup' import { transformSfcRefSugar } from './transformSfcRefSugar' import { resolveOptions } from './options' -const scriptSetupRE = // +export const scriptSetupRE = // export function shouldTransform(code: string, id: string, options?: ScriptSetupTransformOptions): boolean { // avoid transforming twice diff --git a/test/transform_filter.test.ts b/test/transform_filter.test.ts new file mode 100644 index 0000000..7b45978 --- /dev/null +++ b/test/transform_filter.test.ts @@ -0,0 +1,75 @@ +import { } from 'node:test' +import { describe, expect, it } from 'vitest' +import { scriptSetupRE } from '../src/core' + +describe('transform filter', () => { + describe('look for what needs to be converted by regular ', () => { + const cases: string[] = [ + ``, + ``, + ``, + ` + `, + ` + `, + ` + `, + ``, + ] + + for (const input of cases) { + it(input, () => { + expect(scriptSetupRE.test(input)).toEqual(true) + }) + } + }) + + describe('filter what is not needed by regular ', () => { + const cases: string[] = [ + ` + import HelloWorld from './HelloWorld.vue' + + `, + ``, + ` + `, + ] + + for (const input of cases) { + it(input, () => { + expect(scriptSetupRE.test(input)).toEqual(false) + }) + } + }) +})