Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
7ba0173b
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
5992
Star
90
Fork
162
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
18
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
18
Issue
18
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
7ba0173b
编写于
12月 21, 2023
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test: 调整 app 实例示例及测试
上级
c3066529
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
27 addition
and
35 deletion
+27
-35
pages/API/get-app/get-app.test.js
pages/API/get-app/get-app.test.js
+7
-23
pages/API/get-app/get-app.uvue
pages/API/get-app/get-app.uvue
+20
-12
未找到文件。
pages/API/get-app/get-app.test.js
浏览文件 @
7ba0173b
...
...
@@ -8,21 +8,17 @@ describe('getApp', () => {
})
it
(
'
globalData
'
,
async
()
=>
{
await
page
.
callMethod
(
'
getGlobalData
'
)
let
data
=
await
page
.
data
()
let
data
=
await
page
.
data
()
expect
(
data
.
originGlobalData
.
str
).
toBe
(
'
default globalData str
'
)
expect
(
data
.
originGlobalData
.
num
).
toBe
(
0
)
expect
(
data
.
originGlobalData
.
bool
).
toBe
(
false
)
expect
(
data
.
originGlobalData
.
obj
).
toEqual
({
bool
:
false
,
num
:
0
,
str
:
'
default globalData obj str
'
str
:
'
default globalData obj str
'
,
})
expect
(
data
.
originGlobalData
.
arr
).
toEqual
([])
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
data
.
originGlobalData
.
mySet
).
toEqual
([])
}
else
{
expect
(
data
.
originGlobalData
.
mySet
).
toEqual
({})
}
expect
(
data
.
originGlobalData
.
mySet
).
toEqual
([])
expect
(
data
.
originGlobalData
.
myMap
).
toEqual
({})
expect
(
data
.
originGlobalDataFuncRes
).
toBe
(
'
globalData func
'
)
await
page
.
callMethod
(
'
setGlobalData
'
)
...
...
@@ -33,23 +29,11 @@ describe('getApp', () => {
expect
(
data
.
newGlobalData
.
obj
).
toEqual
({
bool
:
true
,
num
:
200
,
str
:
'
new globalData obj str
'
str
:
'
new globalData obj str
'
,
})
expect
(
data
.
newGlobalData
.
arr
).
toEqual
([
1
,
2
,
3
])
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
data
.
newGlobalData
.
mySet
).
toEqual
([
'
a
'
,
'
b
'
,
'
c
'
])
}
else
{
expect
(
data
.
originGlobalData
.
mySet
).
toEqual
({})
}
if
(
process
.
env
.
uniTestPlatformInfo
.
startsWith
(
'
android
'
))
{
expect
(
data
.
newGlobalData
.
myMap
).
toEqual
({
'
a
'
:
1
,
'
b
'
:
2
,
'
c
'
:
3
})
}
else
{
expect
(
data
.
originGlobalData
.
myMap
).
toEqual
({})
}
expect
(
data
.
newGlobalData
.
mySet
).
toEqual
([
'
a
'
,
'
b
'
,
'
c
'
])
expect
(
data
.
newGlobalData
.
myMap
).
toEqual
({
a
:
1
,
b
:
2
,
c
:
3
})
expect
(
data
.
newGlobalDataFuncRes
).
toBe
(
'
new globalData func
'
)
})
it
(
'
method
'
,
async
()
=>
{
...
...
@@ -59,4 +43,4 @@ describe('getApp', () => {
expect
(
newLifeCycleNum
-
oldLifeCycleNum
).
toBe
(
100
)
await
page
.
callMethod
(
'
setLifeCycleNum
'
,
oldLifeCycleNum
)
})
})
})
pages/API/get-app/get-app.uvue
浏览文件 @
7ba0173b
...
...
@@ -18,7 +18,7 @@
<text class="uni-common-mt">globalData Map: {{ originGlobalData.myMap }}</text>
<text class="uni-common-mt">globalData func 返回值: {{ originGlobalDataFuncRes }}</text>
</template>
<button @click="setGlobalData" class="uni-common-mt">
myS
et globalData</button>
<button @click="setGlobalData" class="uni-common-mt">
s
et globalData</button>
<template v-if="newGlobalData.bool">
<text class="uni-common-mt bold">更新后的 globalData:</text>
<text class="uni-common-mt">globalData string: {{ newGlobalData.str }}</text>
...
...
@@ -53,8 +53,8 @@
obj : UTSJSONObject,
null : string | null,
arr : number[],
mySet :
Set<string>
,
myMap :
Map<string, any>
,
mySet :
string[]
,
myMap :
UTSJSONObject
,
func : () => string
}
import { state, setLifeCycleNum } from '@/store/index.uts'
...
...
@@ -73,8 +73,8 @@
} as UTSJSONObject,
null: null,
arr: [] as number[],
mySet:
new Set<string>()
,
myMap:
new Map<string, any>()
,
mySet:
[] as string[]
,
myMap:
{}
,
func: () : string => ''
} as MyGlobalData,
originGlobalDataFuncRes: '',
...
...
@@ -89,8 +89,8 @@
} as UTSJSONObject,
null: null,
arr: [] as number[],
mySet:
new Set<string>(),
myMap:
new Map<string, any>()
,
mySet:
[] as string[],
myMap:
{}
,
func: () : string => ''
} as MyGlobalData,
newGlobalDataFuncRes: '',
...
...
@@ -108,9 +108,13 @@
this.originGlobalData.bool = app.globalData.bool
this.originGlobalData.obj = app.globalData.obj
this.originGlobalData.null = app.globalData.null
this.originGlobalData.arr = app.globalData.arr
this.originGlobalData.mySet = app.globalData.mySet
this.originGlobalData.myMap = app.globalData.myMap
this.originGlobalData.arr = app.globalData.arr
app.globalData.mySet.forEach(value => {
this.originGlobalData.mySet.push(value)
})
app.globalData.myMap.forEach((value, key) => {
this.originGlobalData.myMap[key] = value
})
this.originGlobalData.func = app.globalData.func
this.originGlobalDataFuncRes = this.originGlobalData.func()
},
...
...
@@ -143,8 +147,12 @@
this.newGlobalData.obj = app.globalData.obj
this.newGlobalData.null = app.globalData.null
this.newGlobalData.arr = app.globalData.arr
this.newGlobalData.mySet = app.globalData.mySet
this.newGlobalData.myMap = app.globalData.myMap
app.globalData.mySet.forEach(value => {
this.newGlobalData.mySet.push(value)
})
app.globalData.myMap.forEach((value, key) => {
this.newGlobalData.myMap[key] = value
})
this.newGlobalData.func = app.globalData.func
this.newGlobalDataFuncRes = this.newGlobalData.func()
},
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录