From c0bf140523bc9fc701c9751651b1a263fd0b0b9d Mon Sep 17 00:00:00 2001 From: yusjie <280387025@qq.com> Date: Thu, 18 Jan 2024 09:15:36 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20taro-cli-convertor=E9=83=A8=E5=88=86?= =?UTF-8?q?=E6=97=A5=E5=BF=97=E6=B5=8B=E8=AF=95=E7=94=A8=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../__tests__/config.test.ts | 58 +++++++++++++++++++ 1 file changed, 58 insertions(+) diff --git a/packages/taro-cli-convertor/__tests__/config.test.ts b/packages/taro-cli-convertor/__tests__/config.test.ts index 4b15605ce22c..9662edbbfddf 100644 --- a/packages/taro-cli-convertor/__tests__/config.test.ts +++ b/packages/taro-cli-convertor/__tests__/config.test.ts @@ -536,5 +536,63 @@ describe('生成转换报告及日志', () => { expect(resFileMap.has('/wxProject/taroConvert/report/static/css')).toBeTruthy() expect(resFileMap.has('/wxProject/taroConvert/report/static/media')).toBeTruthy() }) + + test('utils文件中不存在index.js文件', () => { + const UTILS_NO_INDEXJS_FILE = { + '/pages': { + '/index': { + '/index.js': ` + const utils = require("../../utils") + Page ({ + onLoad: function() { + utils.myFunction() + } + }) + `, + '/index.json': ` + { + "usingComponents": { + "utils": "/utils/utils" + } + } + `, + '/index.wxml': ``, + '/index.wxss': '', + } + }, + '/utils': { + '/utils': { + '/utils.js': ` + const myUtil = { + myFunction: function() { + } + } + module.exports = myUtil + `, + '/utils.json': `{}`, + '/utils.wxml': ``, + '/utils.wxss': '', + } + }, + '/project.config.json': `{}`, + '/app.js': `App({})`, + '/app.json': ` + { + "pages":[ + "pages/index/index" + ] + } + `, + } + + setMockFiles(root, UTILS_NO_INDEXJS_FILE) + const convertor = new Convertor(root,false) + convertor.run() + + expect(resFileMap.has('/wxProject/taroConvert/report')).toBeTruthy() + expect(resFileMap.has('/wxProject/taroConvert/report/static/js')).toBeTruthy() + expect(resFileMap.has('/wxProject/taroConvert/report/static/css')).toBeTruthy() + expect(resFileMap.has('/wxProject/taroConvert/report/static/media')).toBeTruthy() + }) }) \ No newline at end of file