提交 6bf6115b 编写于 作者: F fxy060608

调整uts插件keepAlive测试例

上级 e1577be0
......@@ -46,7 +46,7 @@ if (process.env.UNI_PROJECT_TYPE === '2.0' && process.env.uniTestPlatformInfo.to
}
if (process.env.UNI_PROJECT_TYPE === '2.0' && (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios') || process.env.uniTestPlatformInfo.startsWith('android'))) {
describe('testCallbackKeepAlive', () => {
describe('testCallbackKeepAlive2.0', () => {
it("jest_testCallbackKeepAlive", async () => {
const res = await page.callMethod('jest_testCallbackKeepAlive')
expect(res).toEqual(true)
......@@ -55,12 +55,10 @@ if (process.env.UNI_PROJECT_TYPE === '2.0' && (process.env.uniTestPlatformInfo.t
}
if (process.env.UNI_PROJECT_TYPE === '1.0' && (process.env.uniTestPlatformInfo.toLocaleLowerCase().startsWith('ios') || process.env.uniTestPlatformInfo.startsWith('android'))) {
describe('testCallbackKeepAlive', () => {
describe('testCallbackKeepAlive1.0', () => {
it("jest_testCallbackKeepAlive", async () => {
const res = await page.callMethod('jest_testCallbackKeepAlive')
page.waitFor(100)
const count = await page.data('count')
expect(count).toEqual(18)
expect(res).toEqual(20)
})
})
}
......@@ -20,22 +20,22 @@
import {
runTests
} from '../../uni_modules/uts-tests'
import { onTest1, testKeepAlive, testKeepAliveOption, TestKeepAliveClass } from '@/uni_modules/uts-tests'
import { onTest1, testKeepAlive, testKeepAliveOption, createTest, TestKeepAliveClass } from '@/uni_modules/uts-tests'
export default {
data() {
return {
title: 'UTS基础语法',
result: {},
count: 0
result: {}
}
},
onReady() {
this.test()
},
methods: {
test() {
async test() {
this.result = runTests()
console.log(this.result)
console.log('jest_testCallbackKeepAlive:' + await this.jest_testCallbackKeepAlive())
},
jest_testCallbackKeepAlive() {
......@@ -139,10 +139,20 @@
if (count < 2) {
ret = false
}
setTimeout(()=>{
this.count = count
},50)
return ret
// count = 0;
const testImpl = createTest()
testImpl.test((res) => {
count++;
console.log("TestImpl.test callback =====> ", res)
})
if (count < 2) {
ret = false
}
return new Promise((resolve)=>{
setTimeout(()=>{
resolve(count)
},30)
})
}
}
}
......
......@@ -141,5 +141,22 @@ export class TestKeepAliveClass {
option.success?.("2")
}
}
interface ITest {
test(callback : (msg : string) => void) : void
}
class TestImpl implements ITest {
@UTSJS.keepAlive
test(callback : (msg : string) => void) : void {
callback("1")
callback("2")
}
}
export function createTest() : ITest {
return new TestImpl()
}
// #endif
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册