Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
3c30f03d
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6023
Star
91
Fork
164
代码
文件
提交
分支
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看板
提交
3c30f03d
编写于
12月 14, 2023
作者:
雪洛
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat: 移除uniCloud相关测试例的page.waitFor(3000)
上级
47cb066c
变更
6
显示空白变更内容
内联
并排
Showing
6 changed file
with
63 addition
and
68 deletion
+63
-68
pages/API/unicloud-call-function/unicloud-call-function.test.js
...API/unicloud-call-function/unicloud-call-function.test.js
+0
-1
pages/API/unicloud-call-function/unicloud-call-function.uvue
pages/API/unicloud-call-function/unicloud-call-function.uvue
+2
-2
pages/API/unicloud-database/unicloud-database.test.js
pages/API/unicloud-database/unicloud-database.test.js
+6
-15
pages/API/unicloud-database/unicloud-database.uvue
pages/API/unicloud-database/unicloud-database.uvue
+39
-33
pages/API/unicloud-import-object/unicloud-import-object.test.js
...API/unicloud-import-object/unicloud-import-object.test.js
+4
-5
pages/API/unicloud-import-object/unicloud-import-object.uvue
pages/API/unicloud-import-object/unicloud-import-object.uvue
+12
-12
未找到文件。
pages/API/unicloud-call-function/unicloud-call-function.test.js
浏览文件 @
3c30f03d
...
...
@@ -12,7 +12,6 @@ describe('unicloud-call-function', () => {
it
(
'
callFunction
'
,
async
()
=>
{
await
page
.
callMethod
(
'
callFunction
'
)
await
page
.
waitFor
(
3000
)
const
{
callFunctionResult
,
callFunctionError
...
...
pages/API/unicloud-call-function/unicloud-call-function.uvue
浏览文件 @
3c30f03d
...
...
@@ -46,11 +46,11 @@
console.log(title, content)
}
},
callFunction: function ()
{
async callFunction () : Promise<void>
{
uni.showLoading({
title: '加载中...'
})
uniCloud.callFunction({
await
uniCloud.callFunction({
name: 'echo-cf',
data: {
num: 1,
...
...
pages/API/unicloud-database/unicloud-database.test.js
浏览文件 @
3c30f03d
...
...
@@ -11,19 +11,12 @@ describe('unicloud-database', () => {
})
it
(
'
databaseBasic
'
,
async
()
=>
{
await
page
.
callMethod
(
'
dbRemove
'
)
await
page
.
waitFor
(
3000
)
await
page
.
callMethod
(
'
dbAdd
'
)
await
page
.
waitFor
(
1500
)
await
page
.
callMethod
(
'
dbBatchAdd
'
)
await
page
.
waitFor
(
1500
)
await
page
.
callMethod
(
'
dbGet
'
)
await
page
.
waitFor
(
1500
)
await
page
.
callMethod
(
'
dbGetWithCommand
'
)
await
page
.
waitFor
(
1500
)
await
page
.
callMethod
(
'
dbUpdate
'
)
await
page
.
waitFor
(
1500
)
await
page
.
callMethod
(
'
dbRemove
'
)
await
page
.
waitFor
(
1500
)
const
{
addId
,
...
...
@@ -47,9 +40,7 @@ describe('unicloud-database', () => {
it
(
'
databaseLookup
'
,
async
()
=>
{
await
page
.
callMethod
(
'
dbLookupInit
'
)
await
page
.
waitFor
(
3000
)
await
page
.
callMethod
(
'
dbLookup
'
)
await
page
.
waitFor
(
1500
)
const
{
lookupData
...
...
pages/API/unicloud-database/unicloud-database.uvue
浏览文件 @
3c30f03d
...
...
@@ -40,10 +40,15 @@
onLoad() {
},
onUnload() {
if
(this.isUniTest)
{
if
(this.isUniTest)
{
uni.hideToast()
}
},
computed: {
dataTag() : string {
return this.isUniTest ? 'default-tag' + Date.now() : 'default-tag'
}
},
methods: {
notify(content : string, title : string) {
if (!this.isUniTest) {
...
...
@@ -56,18 +61,18 @@
uni.showToast({
title: content
})
console.
log
(title, content)
console.
error
(title, content)
}
},
dbAdd: function ()
{
async dbAdd() : Promise<void>
{
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
db.collection('type')
await
db.collection('type')
.add({
num: 1,
tag:
'default-tag'
,
tag:
this.dataTag
,
date: new Date()
})
.then(res => {
...
...
@@ -82,18 +87,18 @@
this.notify(error.errMsg, '错误')
})
},
dbBatchAdd()
{
async dbBatchAdd() : Promise<void>
{
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
db.collection('type')
await
db.collection('type')
.add([{
num: 2,
tag:
'default-tag'
,
tag:
this.dataTag
,
}, {
num: 3,
tag:
'default-tag'
,
tag:
this.dataTag
,
}])
.then((res) => {
uni.hideLoading()
...
...
@@ -109,14 +114,14 @@
this.notify(error.errMsg, '错误')
})
},
dbGet()
{
async dbGet() : Promise<void>
{
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
db.collection('type')
await
db.collection('type')
.where(
'tag == "default-tag"'
`tag == "${this.dataTag}"`
)
.field('num, tag')
.orderBy('num desc')
...
...
@@ -135,14 +140,15 @@
this.notify(error.errMsg, '错误')
})
},
dbGetWithCommand()
{
async dbGetWithCommand() : Promise<void>
{
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
db.collection('type')
await
db.collection('type')
.where({
num: db.command.gt(1)
num: db.command.gt(1),
tag: this.dataTag
})
.field('num, tag')
.orderBy('num desc')
...
...
@@ -161,14 +167,14 @@
this.notify(error.errMsg, '错误')
})
},
dbUpdate()
{
async dbUpdate() : Promise<void>
{
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
db.collection('type')
await
db.collection('type')
.where(
'tag == "default-tag"'
`tag == "${this.dataTag}"`
)
.update({
num: 4
...
...
@@ -185,14 +191,14 @@
this.notify(error.errMsg, '错误')
})
},
dbRemove()
{
async dbRemove() : Promise<void>
{
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
db.collection('type')
await
db.collection('type')
.where(
'tag == "default-tag"'
`tag == "${this.dataTag}"`
)
.remove()
.then(res => {
...
...
@@ -207,17 +213,17 @@
this.notify(error.errMsg, '错误')
})
},
dbLookupInit()
{
async dbLookupInit() : Promise<void>
{
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
db.collection('local')
.where(
'tag == "default-tag"'
)
await
db.collection('local')
.where(
`tag == "${this.dataTag}"`
)
.remove()
.then(() : Promise<UniCloudDBRemoveResult> => {
return db.collection('foreign')
.where(
'tag == "default-tag"'
)
.where(
`tag == "${this.dataTag}"`
)
.remove()
})
.then(() : Promise<UniCloudDBBatchAddResult> => {
...
...
@@ -225,12 +231,12 @@
.add([{
id: "local_1",
name: "local_1_name",
tag:
"default-tag"
,
tag:
this.dataTag
,
foreign_id: "foreign_1"
}, {
id: "local_2",
name: "local_2_name",
tag:
"default-tag"
,
tag:
this.dataTag
,
foreign_id: "foreign_2"
}])
})
...
...
@@ -239,11 +245,11 @@
.add([{
id: "foreign_1",
name: "foreign_1_name",
tag:
"default-tag"
tag:
this.dataTag
}, {
id: "foreign_2",
name: "foreign_2_name",
tag:
"default-tag"
tag:
this.dataTag
}])
})
.then((_) : void => {
...
...
@@ -257,18 +263,18 @@
this.notify(error.errMsg, '错误')
})
},
dbLookup()
{
async dbLookup() : Promise<void>
{
uni.showLoading({
title: '加载中...'
})
const db = uniCloud.databaseForJQL()
const local = db.collection('local')
.where(
'tag == "default-tag"'
)
.where(
`tag == "${this.dataTag}"`
)
.getTemp()
const foreign = db.collection('foreign')
.where(
'tag == "default-tag"'
)
.where(
`tag == "${this.dataTag}"`
)
.getTemp()
db.collection(local, foreign)
await
db.collection(local, foreign)
.get()
.then(res => {
uni.hideLoading()
...
...
pages/API/unicloud-import-object/unicloud-import-object.test.js
浏览文件 @
3c30f03d
...
...
@@ -13,7 +13,6 @@ describe('unicloud-import-object', () => {
await
page
.
callMethod
(
'
addTodo
'
)
await
page
.
callMethod
(
'
fail
'
)
await
page
.
callMethod
(
'
success
'
)
await
page
.
waitFor
(
3000
)
const
{
todoTitle
,
...
...
pages/API/unicloud-import-object/unicloud-import-object.uvue
浏览文件 @
3c30f03d
...
...
@@ -39,7 +39,7 @@
}
},
onUnload() {
if
(this.isUniTest)
{
if
(this.isUniTest)
{
uni.hideToast()
}
},
...
...
@@ -58,42 +58,42 @@
console.log(title, content)
}
},
a
ddTodo()
{
a
sync addTodo() : Promise<void>
{
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
const title = this.todoTitle
const content = this.todoContent
todo.add(title, content).then((res : UTSJSONObject) : void
=> {
await todo.add(title, content).then((res : UTSJSONObject)
=> {
this.returnTodoTitle = res['title'] as string
this.returnTodoContent = res['content'] as string
this.notify(res['showMessage'] as string, '提示')
}).catch((err : any | null)
: void
=> {
}).catch((err : any | null) => {
const error = err as UniCloudError
console.error(error)
})
},
randomFail()
{
async randomFail() : Promise<void>
{
const todoObj = uniCloud.importObject('todo', {
errorOptions: {
retry: true
}
})
todoObj.randomFail().then((res : UTSJSONObject) : void
=> {
await todoObj.randomFail().then((res : UTSJSONObject)
=> {
this.notify(res['showMessage'] as string, '提示')
}).catch((err : any | null)
: void
=> {
}).catch((err : any | null) => {
const error = err as UniCloudError
console.error(error)
})
},
fail() {
async
fail() {
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
todo.fail().then((res : UTSJSONObject) : void
=> {
await todo.fail().then((res : UTSJSONObject)
=> {
this.notify('todo.fail应调用失败,此处错误的触发了成功回调', '错误')
console.log('todo.fail: ', res);
}).catch((err : any | null)
: void
=> {
}).catch((err : any | null) => {
const error = err as UniCloudError
this.failErrCode = error.errCode as string
console.error(error)
...
...
@@ -108,10 +108,10 @@
const todo = uniCloud.importObject('todo', {
customUI: this.isUniTest
})
todo.success().then((res : UTSJSONObject)
: void
=> {
todo.success().then((res : UTSJSONObject) => {
this.successErrCode = res['errCode'] as number
this.notify(res['showMessage'] as string, '提示')
}).catch((err : any | null)
: void
=> {
}).catch((err : any | null) => {
const error = err as UniCloudError
console.error(error)
})
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录