Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
b457a8b5
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
402
Star
3
Fork
10
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
1
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello-uvue
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
1
Issue
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
b457a8b5
编写于
10月 25, 2023
作者:
H
hdx
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(callMethod): 新增自动化测试
上级
77ca7f38
变更
11
隐藏空白更改
内联
并排
Showing
11 changed file
with
167 addition
and
13 deletion
+167
-13
pages.json
pages.json
+12
-6
pages/component-instance/methods/call-method-easycom-uni-modules.test.js
...-instance/methods/call-method-easycom-uni-modules.test.js
+14
-0
pages/component-instance/methods/call-method-easycom-uni-modules.uvue
...ent-instance/methods/call-method-easycom-uni-modules.uvue
+48
-0
pages/component-instance/methods/call-method-easycom.test.js
pages/component-instance/methods/call-method-easycom.test.js
+14
-0
pages/component-instance/methods/call-method-easycom.uvue
pages/component-instance/methods/call-method-easycom.uvue
+4
-0
pages/component-instance/methods/call-method-other.test.js
pages/component-instance/methods/call-method-other.test.js
+14
-0
pages/component-instance/methods/call-method-other.uvue
pages/component-instance/methods/call-method-other.uvue
+4
-0
pages/component-instance/methods/call-method-uni-element.test.js
...omponent-instance/methods/call-method-uni-element.test.js
+14
-0
pages/component-instance/methods/call-method-uni-element.uvue
...s/component-instance/methods/call-method-uni-element.uvue
+6
-1
pages/index.uvue
pages/index.uvue
+11
-6
uni_modules/call-easy-method/components/call-easy-method-uni-modules/call-easy-method-uni-modules.vue
...-easy-method-uni-modules/call-easy-method-uni-modules.vue
+26
-0
未找到文件。
pages.json
浏览文件 @
b457a8b5
...
@@ -193,21 +193,27 @@
...
@@ -193,21 +193,27 @@
}
}
},
},
{
{
"path"
:
"pages/component-instance/methods/call-
uni-element-method
"
,
"path"
:
"pages/component-instance/methods/call-
method-uni-element
"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"call-
uni-element-method
"
"navigationBarTitleText"
:
"call-
method-uni-element
"
}
}
},
},
{
{
"path"
:
"pages/component-instance/methods/call-
easycom-method
"
,
"path"
:
"pages/component-instance/methods/call-
method-easycom
"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"call-
easycom-method
"
"navigationBarTitleText"
:
"call-
method-easycom
"
}
}
},
},
{
{
"path"
:
"pages/component-instance/methods/call-
other-method
"
,
"path"
:
"pages/component-instance/methods/call-
method-easycom-uni-modules
"
,
"style"
:
{
"style"
:
{
"navigationBarTitleText"
:
"call-other-method"
"navigationBarTitleText"
:
"call-method-easycom-uni-modules"
}
},
{
"path"
:
"pages/component-instance/methods/call-method-other"
,
"style"
:
{
"navigationBarTitleText"
:
"call-method-other"
}
}
},
},
{
{
...
...
pages/component-instance/methods/call-method-easycom-uni-modules.test.js
0 → 100644
浏览文件 @
b457a8b5
const
PAGE_PATH
=
'
/pages/component-instance/methods/call-method-easycom-uni-modules
'
describe
(
'
call-method-easycom-uni-modules
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
callMethodTest
'
,
async
()
=>
{
const
title
=
Date
.
now
()
+
''
const
result
=
await
page
.
callMethod
(
'
callMethodTest
'
,
title
)
expect
(
result
).
toBe
(
title
)
})
})
\ No newline at end of file
pages/component-instance/methods/call-method-easycom-uni-modules.uvue
0 → 100644
浏览文件 @
b457a8b5
<template>
<view>
<call-easy-method-uni-modules ref="callEasyMethod1"></call-easy-method-uni-modules>
</view>
</template>
<script>
export default {
data() {
return {
$callEasyMethod1: null as CallEasyMethodUniModulesComponentPublicInstance | null
}
},
onReady() {
// 通过组件 ref 属性获取组件实例, 组件标签名首字母大写,驼峰+ComponentPublicInstance
this.$callEasyMethod1 = this.$refs['callEasyMethod1'] as CallEasyMethodUniModulesComponentPublicInstance;
},
methods: {
callMethod1() {
// 调用组件的 foo1 方法
this.$callEasyMethod1!.foo1();
},
callMethod2() {
// 调用组件的 foo2 方法并传递 1个参数
this.$callEasyMethod1!.foo2(Date.now());
},
callMethod3() {
// 调用组件的 foo3 方法并传递 2个参数
this.$callEasyMethod1!.foo3(Date.now(), Date.now());
},
callMethod4() {
// 调用组件的 foo4 方法并传递 callback
this.$callEasyMethod1!.foo4(() => {
console.log('callback')
});
},
callMethod5() {
// 注意: 返回值可能为 null,当前例子一定不为空,所以加了 !
const result = this.$callEasyMethod1!.foo5('string1')! as string;
console.log(result); // string1
},
callMethodTest(text: string): string | null {
const result = this.$callEasyMethod1!.foo5(text)! as string;
return result;
},
}
}
</script>
\ No newline at end of file
pages/component-instance/methods/call-method-easycom.test.js
0 → 100644
浏览文件 @
b457a8b5
const
PAGE_PATH
=
'
/pages/component-instance/methods/call-method-easycom
'
describe
(
'
call-method-easycom
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
callMethodTest
'
,
async
()
=>
{
const
title
=
Date
.
now
()
+
''
const
result
=
await
page
.
callMethod
(
'
callMethodTest
'
,
title
)
expect
(
result
).
toBe
(
title
)
})
})
\ No newline at end of file
pages/component-instance/methods/call-
easycom-method
.uvue
→
pages/component-instance/methods/call-
method-easycom
.uvue
浏览文件 @
b457a8b5
...
@@ -39,6 +39,10 @@
...
@@ -39,6 +39,10 @@
const result = this.$callEasyMethod1!.foo5('string1')! as string;
const result = this.$callEasyMethod1!.foo5('string1')! as string;
console.log(result); // string1
console.log(result); // string1
},
},
callMethodTest(text: string): string | null {
const result = this.$callEasyMethod1!.foo5(text)! as string;
return result;
},
}
}
}
}
</script>
</script>
\ No newline at end of file
pages/component-instance/methods/call-method-other.test.js
0 → 100644
浏览文件 @
b457a8b5
const
PAGE_PATH
=
'
/pages/component-instance/methods/call-method-other
'
describe
(
'
call-method-other
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
callMethodTest
'
,
async
()
=>
{
const
title
=
Date
.
now
()
+
''
const
result
=
await
page
.
callMethod
(
'
callMethodTest
'
,
title
)
expect
(
result
).
toBe
(
title
)
})
})
\ No newline at end of file
pages/component-instance/methods/call-
other-method
.uvue
→
pages/component-instance/methods/call-
method-other
.uvue
浏览文件 @
b457a8b5
...
@@ -49,6 +49,10 @@
...
@@ -49,6 +49,10 @@
const result = this.$component1!.$callMethod('foo5', 'string1')! as string;
const result = this.$component1!.$callMethod('foo5', 'string1')! as string;
console.log(result); // string1
console.log(result); // string1
},
},
callMethodTest(text: string): string | null {
const result = this.$component1!.$callMethod('foo5', text)! as string;
return result;
},
}
}
}
}
</script>
</script>
\ No newline at end of file
pages/component-instance/methods/call-method-uni-element.test.js
0 → 100644
浏览文件 @
b457a8b5
const
PAGE_PATH
=
'
/pages/component-instance/methods/call-method-uni-element
'
describe
(
'
call-method-uni-element
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
callMethodTest
'
,
async
()
=>
{
const
title
=
Date
.
now
()
+
''
const
result
=
await
page
.
callMethod
(
'
callMethodTest
'
,
title
)
expect
(
result
).
toBe
(
title
)
})
})
\ No newline at end of file
pages/component-instance/methods/call-
uni-element-method
.uvue
→
pages/component-instance/methods/call-
method-uni-element
.uvue
浏览文件 @
b457a8b5
...
@@ -20,7 +20,12 @@
...
@@ -20,7 +20,12 @@
// 设置组件的 value 属性
// 设置组件的 value 属性
this.$slider1!.value = 80;
this.$slider1!.value = 80;
return true;
return true;
}
},
callMethodTest(text: string): string | null {
this.$slider1!.setAttribute('value', text);
const result = this.$slider1!.getAttribute('value')! as string;
return result;
},
}
}
}
}
</script>
</script>
\ No newline at end of file
pages/index.uvue
浏览文件 @
b457a8b5
...
@@ -288,18 +288,23 @@
...
@@ -288,18 +288,23 @@
enable: true,
enable: true,
},
},
{
{
name: 'call-
uni-element-method
',
name: 'call-
method-uni-element
',
url: 'methods/call-
uni-element-method
',
url: 'methods/call-
method-uni-element
',
enable: true,
enable: true,
},
},
{
{
name: 'call-
easycom-method
',
name: 'call-
method-easycom
',
url: 'methods/call-
easycom-method
',
url: 'methods/call-
method-easycom
',
enable: true,
enable: true,
},
},
{
{
name: 'call-other-method',
name: 'call-method-easycom-uni-modules',
url: 'methods/call-other-method',
url: 'methods/call-method-easycom-uni-modules',
enable: true,
},
{
name: 'call-method-other',
url: 'methods/call-method-other',
enable: true,
enable: true,
},
},
] as PageItem[],
] as PageItem[],
...
...
uni_modules/call-easy-method/components/call-easy-method-uni-modules/call-easy-method-uni-modules.vue
0 → 100644
浏览文件 @
b457a8b5
<
template
>
<view></view>
</
template
>
<
script
>
export
default
{
data
()
{
return
{
}
},
methods
:
{
foo1
()
{
},
foo2
(
date1
:
number
)
{
},
foo3
(
date1
:
number
,
date2
:
number
)
{
},
foo4
(
callback
:
(()
=>
void
))
{
callback
()
},
foo5
(
text1
:
string
)
:
any
|
null
{
return
text1
}
}
}
</
script
>
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录