Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello-uvue
提交
163bc5d9
H
hello-uvue
项目概览
DCloud
/
hello-uvue
通知
347
Star
2
Fork
7
代码
文件
提交
分支
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看板
提交
163bc5d9
编写于
7月 05, 2023
作者:
crlfe
😲
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加组件实例测试用例
上级
9a5603d7
变更
25
隐藏空白更改
内联
并排
Showing
25 changed file
with
187 addition
and
56 deletion
+187
-56
pages/component-instance/attrs/attrs.test.js
pages/component-instance/attrs/attrs.test.js
+19
-0
pages/component-instance/attrs/child.uvue
pages/component-instance/attrs/child.uvue
+3
-3
pages/component-instance/data/data.test.js
pages/component-instance/data/data.test.js
+0
-1
pages/component-instance/data/data.uvue
pages/component-instance/data/data.uvue
+1
-1
pages/component-instance/el/el.test.js
pages/component-instance/el/el.test.js
+11
-2
pages/component-instance/emit-function/child.uvue
pages/component-instance/emit-function/child.uvue
+2
-2
pages/component-instance/emit-function/emit-function.test.js
pages/component-instance/emit-function/emit-function.test.js
+17
-2
pages/component-instance/emit-function/emit-function.uvue
pages/component-instance/emit-function/emit-function.uvue
+3
-3
pages/component-instance/forceUpdate-function/forceUpdate-function.test.js
...nstance/forceUpdate-function/forceUpdate-function.test.js
+0
-5
pages/component-instance/nextTick-function/nextTick-function.test.js
...nent-instance/nextTick-function/nextTick-function.test.js
+0
-5
pages/component-instance/nextTick-function/nextTick-function.uvue
...mponent-instance/nextTick-function/nextTick-function.uvue
+0
-3
pages/component-instance/options/options.test.js
pages/component-instance/options/options.test.js
+11
-2
pages/component-instance/options/options.uvue
pages/component-instance/options/options.uvue
+1
-1
pages/component-instance/parent/child.uvue
pages/component-instance/parent/child.uvue
+7
-4
pages/component-instance/parent/parent.test.js
pages/component-instance/parent/parent.test.js
+23
-2
pages/component-instance/props/check-type.uvue
pages/component-instance/props/check-type.uvue
+3
-3
pages/component-instance/props/props.test.js
pages/component-instance/props/props.test.js
+14
-0
pages/component-instance/refs/refs.test.js
pages/component-instance/refs/refs.test.js
+12
-2
pages/component-instance/refs/refs.uvue
pages/component-instance/refs/refs.uvue
+10
-1
pages/component-instance/root/root.test.js
pages/component-instance/root/root.test.js
+12
-2
pages/component-instance/root/root.uvue
pages/component-instance/root/root.uvue
+6
-4
pages/component-instance/slots/slots.test.js
pages/component-instance/slots/slots.test.js
+13
-2
pages/component-instance/slots/slots.uvue
pages/component-instance/slots/slots.uvue
+1
-1
pages/component-instance/watch-function/watch-function.test.js
.../component-instance/watch-function/watch-function.test.js
+15
-2
pages/component-instance/watch-function/watch-function.uvue
pages/component-instance/watch-function/watch-function.uvue
+3
-3
未找到文件。
pages/component-instance/attrs/attrs.test.js
浏览文件 @
163bc5d9
const
PAGE_PATH
=
'
/pages/component-instance/attrs/attrs
'
describe
(
'
$props
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
$attrs中不应该存在$props属性(已在组件props中声明)
'
,
async
()
=>
{
const
val
=
await
page
.
$
(
'
.has-props-attrs
'
)
expect
(
await
val
.
text
()).
toBe
(
'
false
'
)
})
it
(
'
$attrs中不应该存在$emits属性(已在组件emits中声明)
'
,
async
()
=>
{
const
val
=
await
page
.
$
(
'
.has-emits-attrs
'
)
expect
(
await
val
.
text
()).
toBe
(
'
false
'
)
})
it
(
'
$attrs中可以获取到未声明的属性
'
,
async
()
=>
{
const
val
=
await
page
.
$
(
'
.has-attrs
'
)
expect
(
await
val
.
text
()).
toBe
(
'
true
'
)
})
})
pages/component-instance/attrs/child.uvue
浏览文件 @
163bc5d9
...
...
@@ -2,15 +2,15 @@
<view>
<view class="row">
<text>hasPropsAttrs</text>
<text>{{ hasPropsAttrs }}</text>
<text
class="has-props-attrs"
>{{ hasPropsAttrs }}</text>
</view>
<view class="row">
<text>hasEmitsAttr</text>
<text>{{ hasEmitsAttr }}</text>
<text
class="has-emits-attrs"
>{{ hasEmitsAttr }}</text>
</view>
<view class="row">
<text>hasAttrs</text>
<text>{{ hasAttrs }}</text>
<text
class="has-attrs"
>{{ hasAttrs }}</text>
</view>
</view>
</template>
...
...
pages/component-instance/data/data.test.js
浏览文件 @
163bc5d9
...
...
@@ -7,7 +7,6 @@ describe('$data', () => {
await
page
.
waitFor
(
500
)
})
it
(
'
should data.val === 2
'
,
async
()
=>
{
const
plusButton
=
await
page
.
$
(
'
.plus
'
)
await
plusButton
.
tap
()
...
...
pages/component-instance/data/data.uvue
浏览文件 @
163bc5d9
<template>
<view class="page">
<view class="row">初始值: <text>1</text></view>
<view class="row">初始值
1
: <text>1</text></view>
<view class="row">data.val: <text class="val">{{val}}</text></view>
<view class="row">data._val: <text class="_val">{{_val}}</text></view>
<view class="row">data.$val: <text class="$val">{{$val}}</text></view>
...
...
pages/component-instance/el/el.test.js
浏览文件 @
163bc5d9
const
PAGE_PATH
=
'
/pages/component-instance/
props/props
'
const
PAGE_PATH
=
'
/pages/component-instance/
el/el
'
describe
(
'
$props
'
,
()
=>
{
describe
(
'
$el
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
$el元素可用
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.tag-name
'
)
expect
(
await
el
.
text
()).
toBe
(
'
view
'
)
})
})
pages/component-instance/emit-function/child.uvue
浏览文件 @
163bc5d9
<template>
<view>
<button @click="click">调用父组件事件</button>
<button @click="click"
class="call-parent-btn"
>调用父组件事件</button>
</view>
</template>
...
...
@@ -9,7 +9,7 @@ export default {
emits: ['callback'],
methods: {
click () {
this.$emit('callback',
'string',
`${Date.now()}`)
this.$emit('callback', `${Date.now()}`)
}
}
}
...
...
pages/component-instance/emit-function/emit-function.test.js
浏览文件 @
163bc5d9
const
PAGE_PATH
=
'
/pages/component-instance/
props/props
'
const
PAGE_PATH
=
'
/pages/component-instance/
emit-function/emit-function
'
describe
(
'
$props
'
,
()
=>
{
describe
(
'
$emit()
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
$emit() 事件生效
'
,
async
()
=>
{
const
beforeValue
=
await
page
.
data
(
'
value
'
)
const
btn
=
await
page
.
$
(
'
.call-parent-btn
'
)
btn
.
tap
()
const
afterValue
=
await
page
.
data
(
'
value
'
)
expect
(
beforeValue
).
not
.
toBe
(
afterValue
)
})
})
pages/component-instance/emit-function/emit-function.uvue
浏览文件 @
163bc5d9
...
...
@@ -19,12 +19,12 @@ export default {
},
data () {
return {
value:
[] as string[]
value:
""
}
},
methods: {
callback (str: string
, str1: string
) {
this.value =
[str, str1]
callback (str: string) {
this.value =
str
}
}
}
...
...
pages/component-instance/forceUpdate-function/forceUpdate-function.test.js
已删除
100644 → 0
浏览文件 @
9a5603d7
const
PAGE_PATH
=
'
/pages/component-instance/props/props
'
describe
(
'
$props
'
,
()
=>
{
})
pages/component-instance/nextTick-function/nextTick-function.test.js
已删除
100644 → 0
浏览文件 @
9a5603d7
const
PAGE_PATH
=
'
/pages/component-instance/props/props
'
describe
(
'
$props
'
,
()
=>
{
})
pages/component-instance/nextTick-function/nextTick-function.uvue
浏览文件 @
163bc5d9
...
...
@@ -7,9 +7,6 @@
</template>
<script lang="ts">
type Obj = {
key: string
}
export default {
data () {
return {
...
...
pages/component-instance/options/options.test.js
浏览文件 @
163bc5d9
const
PAGE_PATH
=
'
/pages/component-instance/
props/prop
s
'
const
PAGE_PATH
=
'
/pages/component-instance/
options/option
s
'
describe
(
'
$props
'
,
()
=>
{
describe
(
'
$options
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
获取到组件name属性
'
,
async
()
=>
{
const
data
=
await
page
.
data
()
expect
(
data
.
name
).
toBe
(
'
$options
'
)
});
})
pages/component-instance/options/options.uvue
浏览文件 @
163bc5d9
...
...
@@ -2,7 +2,7 @@
<view class="page">
<view class="row">
<text>name: </text>
<text>{{name}}</text>
<text
class="value"
>{{name}}</text>
</view>
</view>
</template>
...
...
pages/component-instance/parent/child.uvue
浏览文件 @
163bc5d9
<template>
<view class="child">
<view>{{value}}</view>
<view class="parent-text">{{value}}</view>
<view class="parent-func-text">{{callbackValue}}</view>
<button @click="testFunction" class="call-parent-func">调用父组件方法</button>
</view>
</template>
...
...
@@ -8,15 +10,16 @@
export default {
data () {
return {
value: "child"
value: "child",
callbackValue: ""
}
},
mounted () {
this.value = this.$parent!.$data['value'] as string
},
methods: {
testFunction ()
: string
{
return
this.$parent!.$callMethod('testFunction') as string
testFunction () {
this.callbackValue =
this.$parent!.$callMethod('testFunction') as string
}
}
}
...
...
pages/component-instance/parent/parent.test.js
浏览文件 @
163bc5d9
const
PAGE_PATH
=
'
/pages/component-instance/p
rops/props
'
const
PAGE_PATH
=
'
/pages/component-instance/p
arent/parent
'
describe
(
'
$props
'
,
()
=>
{
describe
(
'
$parent
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
$parent 属性生效
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.parent-text
'
)
expect
(
await
el
.
text
()).
toBe
(
'
parent
'
)
});
it
(
'
调用$parent方法正常
'
,
async
()
=>
{
const
el
=
await
page
.
$
(
'
.parent-func-text
'
)
const
btn
=
await
page
.
$
(
'
.call-parent-func
'
)
btn
.
tap
()
await
page
.
waitFor
(
1000
)
expect
(
await
el
.
text
()).
toBe
(
'
parentFunctionResult
'
)
})
})
pages/component-instance/props/check-type.uvue
浏览文件 @
163bc5d9
<template>
<view class="component">
<view class="row">
<text>string: </text><text>{{str}}</text>
<text>string: </text><text
class="string"
>{{str}}</text>
</view>
<view class="row">
<text>num: </text><text>{{num}}</text>
<text>num: </text><text
class="number"
>{{num}}</text>
</view>
<view class="row">
<text>bool: </text><text>{{bool}}</text>
<text>bool: </text><text
class="boolean"
>{{bool}}</text>
</view>
<!-- <view class="row">-->
<!-- <text>arr: </text>-->
...
...
pages/component-instance/props/props.test.js
浏览文件 @
163bc5d9
const
PAGE_PATH
=
'
/pages/component-instance/props/props
'
describe
(
'
$props
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
$props 属性生效
'
,
async
()
=>
{
const
string
=
await
page
.
$
(
'
.string
'
)
const
number
=
await
page
.
$
(
'
.number
'
)
const
boolean
=
await
page
.
$
(
'
.boolean
'
)
expect
(
await
string
.
text
()).
toBe
(
'
abcd
'
)
expect
(
await
number
.
text
()).
toBe
(
'
12345
'
)
expect
(
await
boolean
.
text
()).
toBe
(
'
true
'
)
})
})
pages/component-instance/refs/refs.test.js
浏览文件 @
163bc5d9
const
PAGE_PATH
=
'
/pages/component-instance/
props/prop
s
'
const
PAGE_PATH
=
'
/pages/component-instance/
refs/ref
s
'
describe
(
'
$props
'
,
()
=>
{
describe
(
'
$refs
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
$refs 属性生效
'
,
async
()
=>
{
const
data
=
await
page
.
data
()
expect
(
data
.
existRef
).
toBe
(
true
)
});
})
pages/component-instance/refs/refs.uvue
浏览文件 @
163bc5d9
<template>
<view class="page">
<view ref="node">NodeRef</view>
<view ref="node">NodeRef
: {{existRef}}
</view>
<!-- <child ref="component">ComponentRef</child>-->
</view>
</template>
...
...
@@ -12,7 +12,16 @@ export default {
// components: {
// child
// },
data () {
return {
existRef: false
}
},
mounted () {
const nodeRef = this.$refs.get('node')
this.existRef = nodeRef !== null
console.log(this.$refs)
}
}
...
...
pages/component-instance/root/root.test.js
浏览文件 @
163bc5d9
const
PAGE_PATH
=
'
/pages/component-instance/
props/props
'
const
PAGE_PATH
=
'
/pages/component-instance/
root/root
'
describe
(
'
$props
'
,
()
=>
{
describe
(
'
$root
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
$root 属性生效
'
,
async
()
=>
{
const
root
=
await
page
.
callMethod
(
'
getRoot
'
)
expect
(
root
).
toBe
(
true
)
})
})
pages/component-instance/root/root.uvue
浏览文件 @
163bc5d9
<template>
<view class="page">
<view class="row">root
IsApp: <text>{{isApp
}}</text></view>
<view class="row">root
: <text>{{root
}}</text></view>
</view>
</template>
...
...
@@ -8,11 +8,13 @@
export default {
data () {
return {
isApp: fals
e
root: tru
e
}
},
mounted () {
// this.isApp = this.$root.app
methods: {
getRoot (): boolean {
return this.$root!.$data.get('root') as boolean
}
}
}
</script>
...
...
pages/component-instance/slots/slots.test.js
浏览文件 @
163bc5d9
const
PAGE_PATH
=
'
/pages/component-instance/
props/prop
s
'
const
PAGE_PATH
=
'
/pages/component-instance/
slots/slot
s
'
describe
(
'
$props
'
,
()
=>
{
describe
(
'
$slots
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
$slots 生效
'
,
async
()
=>
{
const
slotComp
=
await
page
.
$
(
'
.slot-comp
'
)
const
hasSlots
=
await
slotComp
.
callMethod
(
'
hasSlots
'
)
expect
(
hasSlots
).
toBe
(
true
)
})
})
pages/component-instance/slots/slots.uvue
浏览文件 @
163bc5d9
<template>
<view class="page">
<slot-comp>
<slot-comp
class="slot-comp"
>
<template v-slot:header>header</template>
<template v-slot:footer>footer</template>
</slot-comp>
...
...
pages/component-instance/watch-function/watch-function.test.js
浏览文件 @
163bc5d9
const
PAGE_PATH
=
'
/pages/component-instance/
props/props
'
const
PAGE_PATH
=
'
/pages/component-instance/
watch-function/watch-function
'
describe
(
'
$props
'
,
()
=>
{
describe
(
'
$watch()
'
,
()
=>
{
let
page
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
500
)
})
it
(
'
$watch() 生效
'
,
async
()
=>
{
const
initValue
=
(
await
page
.
$
(
'
.init
'
)).
text
()
const
value
=
await
(
await
page
.
data
()).
val
const
isChange
=
await
(
await
page
.
data
()).
changed
expect
(
value
).
not
.
toBe
(
initValue
)
expect
(
isChange
).
toBe
(
true
)
})
})
pages/component-instance/watch-function/watch-function.uvue
浏览文件 @
163bc5d9
...
...
@@ -2,7 +2,7 @@
<view class="page">
<view class="row">
<text>初始值</text>
<text>init</text>
<text
class="init-value"
>init</text>
</view>
<view class="row">
<text>val</text>
...
...
@@ -27,8 +27,8 @@ export default {
return {
val: "init",
changed: false,
a: 'a',
b: 'b',
//
a: 'a',
//
b: 'b',
// abChanged: false
}
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录