diff --git a/pages/index/basicTest.test.js b/pages/index/basicTest.test.js index 35a3c6782ec547403350f5cc6cdf695b6b79769e..1f075350beb67c7b900db9cc2e7b8c17a9538faa 100644 --- a/pages/index/basicTest.test.js +++ b/pages/index/basicTest.test.js @@ -3,35 +3,44 @@ 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.toLocaleLowerCase().startsWith('ios')) { + describe('testTypeFromAppJs', () => { + it("jest_testTypeFromAppJs", async () => { + 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 b569f602252e0491bcea38fb8a6fa0276793d0d2..6d3ba41c59e02e48dd5d973ee86adb62551e68d3 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 0000000000000000000000000000000000000000..e69de29bb2d1d6434b8b29ae775ad8c2e48c5391 diff --git a/uni_modules/uts-ios-tests/package.json b/uni_modules/uts-ios-tests/package.json new file mode 100644 index 0000000000000000000000000000000000000000..a7d9e822ccf8a3ca0822c22c7fadd612d80885ce --- /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 0000000000000000000000000000000000000000..b2dc001c0b9e01582dc01f9854d59e8c3641f1fa --- /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 0000000000000000000000000000000000000000..41917fff4c95870abd4d0ac4d4c8f90d82564c9c --- /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 0000000000000000000000000000000000000000..7854a893c3c7a042d6595b857832980db223b459 --- /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 diff --git a/uni_modules/uts-tests/utssdk/Date.uts b/uni_modules/uts-tests/utssdk/Date.uts index 2b9dd0bfef70036195f435c14222f7df4d1d79c5..fd805481109b1d4cccacc48510eb1af459c4ef2e 100644 --- a/uni_modules/uts-tests/utssdk/Date.uts +++ b/uni_modules/uts-tests/utssdk/Date.uts @@ -44,7 +44,29 @@ export function testDate() : Result { // expect(date1.toTimeString()).toEqual("08:00:00 GMT+0800"); // expect(date2.toTimeString()).toEqual("03:24:00 GMT+0800"); // // #endif - }) + }) + + test('toXString', () => { + const event = new Date('1995-12-17T03:24:00'); + // #ifndef APP-ANDROID + expect(event.toString()).toEqual("Sun Dec 17 1995 03:24:00 GMT+0800"); + expect(event.toTimeString()).toEqual("03:24:00 GMT+0800"); + // #endif + expect(event.toISOString()).toEqual("1995-12-16T19:24:00.000Z"); + expect(event.toJSON()).toEqual("1995-12-16T19:24:00.000Z"); + expect(event.toDateString()).toEqual("Sun Dec 17 1995"); + + const event2 = new Date('2014-01-09 22:00:00'); + // #ifndef APP-ANDROID + expect(event2.toString()).toEqual("Thu Jan 09 2014 22:00:00 GMT+0800"); + expect(event2.toTimeString()).toEqual("2014-01-09T14:00:00.000Z"); + // #endif + expect(event2.toISOString()).toEqual("2014-01-09T14:00:00.000Z"); + expect(event2.toJSON()).toEqual("Thu Jan 09 2014"); + expect(event2.toDateString()).toEqual("22:00:00 GMT+0800"); + + }) + test('getDate', () => { const birthday = new Date('August 19, 1975 23:15:30');