From d29d01d502d9b3a3aa72a96ec1901faea1761eb5 Mon Sep 17 00:00:00 2001 From: wangyaqi Date: Mon, 8 Apr 2024 15:24:23 +0800 Subject: [PATCH] =?UTF-8?q?test:=20=E5=A2=9E=E5=8A=A0iOS=E7=AB=AF=E5=BC=95?= =?UTF-8?q?=E7=94=A8app-js=E5=86=85=E7=B1=BB=E5=9E=8B=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/index/basicTest.test.js | 57 +++++++------ pages/index/basicTest.uvue | 14 +++- uni_modules/uts-ios-tests/changelog.md | 0 uni_modules/uts-ios-tests/package.json | 82 +++++++++++++++++++ uni_modules/uts-ios-tests/readme.md | 6 ++ .../uts-ios-tests/utssdk/app-js/index.uts | 9 ++ .../uts-ios-tests/utssdk/interface.uts | 3 + 7 files changed, 144 insertions(+), 27 deletions(-) create mode 100644 uni_modules/uts-ios-tests/changelog.md create mode 100644 uni_modules/uts-ios-tests/package.json create mode 100644 uni_modules/uts-ios-tests/readme.md create mode 100644 uni_modules/uts-ios-tests/utssdk/app-js/index.uts create mode 100644 uni_modules/uts-ios-tests/utssdk/interface.uts diff --git a/pages/index/basicTest.test.js b/pages/index/basicTest.test.js index 35a3c67..22bf972 100644 --- a/pages/index/basicTest.test.js +++ b/pages/index/basicTest.test.js @@ -3,35 +3,42 @@ const ERR_RE = /expected:<(.*)> but was:<(.*)>/ let result; beforeAll(async () => { - await program.reLaunch('/pages/index/basicTest') - page = await program.currentPage() - await page.waitFor(3000); - const data = await page.data(); - result = data['result'] + await program.reLaunch('/pages/index/basicTest') + page = await program.currentPage() + await page.waitFor(3000); + const data = await page.data(); + result = data['result'] }) function getApiFailed(describe, api) { - const failed = result[describe]?.failed?.find(item => { - return item.split(':')[0] === api - }) - return failed + const failed = result[describe]?.failed?.find(item => { + return item.split(':')[0] === api + }) + return failed } describes.forEach(d => { - d?.describe && describe(d.describe, () => { - d?.tests && d.tests.forEach(api => { - it(api, ()=>{ - const failed = getApiFailed(d.describe, api) - if (failed) { - const parts = failed.split('\n') - const matches = parts[1].match(ERR_RE) - if (matches?.length) { - expect(matches[2]).toEqual(matches[1]) - } else { - expect(parts[1]).toEqual('') - } - } - }) - }) - }) + d?.describe && describe(d.describe, () => { + d?.tests && d.tests.forEach(api => { + it(api, () => { + const failed = getApiFailed(d.describe, api) + if (failed) { + const parts = failed.split('\n') + const matches = parts[1].match(ERR_RE) + if (matches?.length) { + expect(matches[2]).toEqual(matches[1]) + } else { + expect(parts[1]).toEqual('') + } + } + }) + }) + }) }) + +if (process.env.uniTestPlatformInfo.startsWith('ios')) { + describe('testTypeFromAppJs', () => { + const res = await page.callMethod('jest_testTypeFromAppJs') + expect(res).toEqual(true) + }) +} \ No newline at end of file diff --git a/pages/index/basicTest.uvue b/pages/index/basicTest.uvue index b569f60..6d3ba41 100644 --- a/pages/index/basicTest.uvue +++ b/pages/index/basicTest.uvue @@ -20,7 +20,10 @@ diff --git a/uni_modules/uts-ios-tests/changelog.md b/uni_modules/uts-ios-tests/changelog.md new file mode 100644 index 0000000..e69de29 diff --git a/uni_modules/uts-ios-tests/package.json b/uni_modules/uts-ios-tests/package.json new file mode 100644 index 0000000..a7d9e82 --- /dev/null +++ b/uni_modules/uts-ios-tests/package.json @@ -0,0 +1,82 @@ +{ + "id": "uts-ios-tests", + "displayName": "uts-ios-tests", + "version": "1.0.0", + "description": "uts-ios-tests", + "keywords": [ + "uts-ios-tests" +], + "repository": "", + "engines": { + "HBuilderX": "^3.6.8" + }, + "dcloudext": { + "type": "uts", + "sale": { + "regular": { + "price": "0.00" + }, + "sourcecode": { + "price": "0.00" + } + }, + "contact": { + "qq": "" + }, + "declaration": { + "ads": "", + "data": "", + "permissions": "" + }, + "npmurl": "" + }, + "uni_modules": { + "dependencies": [], + "encrypt": [], + "platforms": { + "cloud": { + "tcb": "u", + "aliyun": "u", + "alipay": "u" + }, + "client": { + "Vue": { + "vue2": "u", + "vue3": "u" + }, + "App": { + "app-android": "u", + "app-ios": "u" + }, + "H5-mobile": { + "Safari": "u", + "Android Browser": "u", + "微信浏览器(Android)": "u", + "QQ浏览器(Android)": "u" + }, + "H5-pc": { + "Chrome": "u", + "IE": "u", + "Edge": "u", + "Firefox": "u", + "Safari": "u" + }, + "小程序": { + "微信": "u", + "阿里": "u", + "百度": "u", + "字节跳动": "u", + "QQ": "u", + "钉钉": "u", + "快手": "u", + "飞书": "u", + "京东": "u" + }, + "快应用": { + "华为": "u", + "联盟": "u" + } + } + } + } +} \ No newline at end of file diff --git a/uni_modules/uts-ios-tests/readme.md b/uni_modules/uts-ios-tests/readme.md new file mode 100644 index 0000000..b2dc001 --- /dev/null +++ b/uni_modules/uts-ios-tests/readme.md @@ -0,0 +1,6 @@ +# uts-ios-tests +### 开发文档 +[UTS 语法](https://uniapp.dcloud.net.cn/tutorial/syntax-uts.html) +[UTS API插件](https://uniapp.dcloud.net.cn/plugin/uts-plugin.html) +[UTS 组件插件](https://uniapp.dcloud.net.cn/plugin/uts-component.html) +[Hello UTS](https://gitcode.net/dcloud/hello-uts) \ No newline at end of file diff --git a/uni_modules/uts-ios-tests/utssdk/app-js/index.uts b/uni_modules/uts-ios-tests/utssdk/app-js/index.uts new file mode 100644 index 0000000..41917ff --- /dev/null +++ b/uni_modules/uts-ios-tests/utssdk/app-js/index.uts @@ -0,0 +1,9 @@ +import { Options } from '../interface.uts'; + +export function testTypeFromAppJs(options : Options) { + return options instanceof Options +} + +export { + Options +} \ No newline at end of file diff --git a/uni_modules/uts-ios-tests/utssdk/interface.uts b/uni_modules/uts-ios-tests/utssdk/interface.uts new file mode 100644 index 0000000..7854a89 --- /dev/null +++ b/uni_modules/uts-ios-tests/utssdk/interface.uts @@ -0,0 +1,3 @@ +export type Options = { + num: number +} \ No newline at end of file -- GitLab