From 82c2938d1d7305c37def5d68109d9d088687cd5d Mon Sep 17 00:00:00 2001 From: weishanchao <18178209323@163.com> Date: Mon, 12 Aug 2024 10:50:32 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8Dframework=E7=9A=84?= =?UTF-8?q?=E9=94=99=E8=AF=AF=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/taro-cli/src/__tests__/doctor-config.spec.ts | 5 +++-- packages/taro-cli/src/__tests__/utils/index.ts | 5 +++++ 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/packages/taro-cli/src/__tests__/doctor-config.spec.ts b/packages/taro-cli/src/__tests__/doctor-config.spec.ts index 07f48bbb967c..0a9c5b381938 100644 --- a/packages/taro-cli/src/__tests__/doctor-config.spec.ts +++ b/packages/taro-cli/src/__tests__/doctor-config.spec.ts @@ -1,6 +1,7 @@ import * as helper from '@tarojs/helper' import doctor from '../doctor' +import { validateFramework } from './utils/index' const validator = doctor.validators[1] const baseConfig = { @@ -49,7 +50,7 @@ describe('config validator of doctor', () => { expect(messages.length).toEqual(3) msgs = messages.map(line => line.content) - expect(msgs.includes('framework 的值 "" 与任何指定选项 ["nerv","react","preact","solid","vue","vue3","none"] 都不匹配')).toBeTruthy() + expect(validateFramework(msgs)).toBeTruthy() }) it('date', async () => { @@ -93,7 +94,7 @@ describe('config validator of doctor', () => { framework: 'other' })) expect(res.messages.length).toEqual(3) - expect(res.messages[2].content).toEqual('framework 的值 "other" 与任何指定选项 ["nerv","react","preact","solid","vue","vue3","none"] 都不匹配') + expect(validateFramework(res.messages[2].content)).toEqual(true) }) it('designWidth', async () => { diff --git a/packages/taro-cli/src/__tests__/utils/index.ts b/packages/taro-cli/src/__tests__/utils/index.ts index 6dc71ae687f3..8616ef897425 100644 --- a/packages/taro-cli/src/__tests__/utils/index.ts +++ b/packages/taro-cli/src/__tests__/utils/index.ts @@ -52,3 +52,8 @@ export function run (name: string, presets: string[] = []): IRun { return kernel } } + +export function validateFramework(value: string) { + const frameworkRegex = /(nerv|react|preact|solid|vue|vue3|none)/ + return frameworkRegex.test(value) +}