Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
DCloud
hello uni-app x
提交
b01bec96
H
hello uni-app x
项目概览
DCloud
/
hello uni-app x
通知
6058
Star
93
Fork
166
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
19
列表
看板
标记
里程碑
合并请求
1
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
H
hello uni-app x
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
19
Issue
19
列表
看板
标记
里程碑
合并请求
1
合并请求
1
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
提交
b01bec96
编写于
12月 07, 2024
作者:
DCloud-WZF
💬
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
test(getLocation): 优化代码,规避小程序平台
上级
bee1bb12
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
64 addition
and
64 deletion
+64
-64
pages/API/get-location/get-location.test.js
pages/API/get-location/get-location.test.js
+64
-64
未找到文件。
pages/API/get-location/get-location.test.js
浏览文件 @
b01bec96
const
PAGE_PATH
=
"
/pages/API/get-location/get-location
"
;
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIos
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isApp
=
isAndroid
||
isIos
const
PAGE_PATH
=
"
/pages/API/get-location/get-location
"
;
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isAndroid
=
platformInfo
.
startsWith
(
'
android
'
)
const
isIos
=
platformInfo
.
startsWith
(
'
ios
'
)
const
isApp
=
isAndroid
||
isIos
const
isWeb
=
platformInfo
.
startsWith
(
'
web
'
)
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
describe
(
"
get-location
"
,
()
=>
{
const
platformInfo
=
process
.
env
.
uniTestPlatformInfo
.
toLocaleLowerCase
()
const
isMP
=
platformInfo
.
startsWith
(
'
mp
'
)
if
(
isMP
)
{
// 微信上会有权限弹框,暂时屏蔽测试
it
(
'
not support
'
,
async
()
=>
{
expect
(
1
).
toBe
(
1
)
})
}
describe
(
"
get-location
"
,
()
=>
{
if
(
isMP
)
{
// 微信上会有权限弹框,暂时屏蔽测试
it
(
'
not support
'
,
async
()
=>
{
expect
(
1
).
toBe
(
1
)
})
return
}
beforeAll
(
async
()
=>
{
page
=
await
program
.
reLaunch
(
PAGE_PATH
)
await
page
.
waitFor
(
600
)
});
});
//system 定位
it
(
"
system+type=wgs84+success
"
,
async
()
=>
{
it
(
"
system+type=wgs84+success
"
,
async
()
=>
{
await
page
.
setData
({
jest_provider
:
'
system
'
,
...
...
@@ -33,11 +33,11 @@ describe("get-location", () => {
await
page
.
waitFor
(
async
()
=>
{
return
await
page
.
data
(
'
jest_complete
'
)
===
true
;
});
const
data
=
await
page
.
data
()
const
jest_errCode
=
data
[
'
jest_errCode
'
]
const
jest_errCode
=
data
[
'
jest_errCode
'
]
if
(
jest_errCode
>
0
)
{
if
(
jest_errCode
>
0
)
{
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
expect
.
any
(
Number
));
}
else
{
//判断经纬度是否在正常范围
...
...
@@ -48,10 +48,10 @@ describe("get-location", () => {
//判断海拔是否正确
expect
((
await
page
.
data
())[
'
jest_altitude
'
]).
toEqual
(
expect
.
any
(
Number
));
}
});
});
//system 定位
it
(
"
system+type=wgs84+success+geocode=true
"
,
async
()
=>
{
it
(
"
system+type=wgs84+success+geocode=true
"
,
async
()
=>
{
await
page
.
setData
({
jest_provider
:
'
system
'
,
...
...
@@ -64,45 +64,45 @@ describe("get-location", () => {
await
page
.
waitFor
(
async
()
=>
{
return
await
page
.
data
(
'
jest_complete
'
)
===
true
;
});
const
data
=
await
page
.
data
()
const
jest_errCode
=
data
[
'
jest_errCode
'
]
if
(
jest_errCode
>
0
)
{
if
(
isIos
)
{
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
1505603
);
}
else
if
(
isAndroid
)
{
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
1505700
);
}
else
{
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
expect
.
any
(
Number
));
const
jest_errCode
=
data
[
'
jest_errCode
'
]
if
(
jest_errCode
>
0
)
{
if
(
isIos
)
{
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
1505603
);
}
else
if
(
isAndroid
)
{
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
1505700
);
}
else
{
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
expect
.
any
(
Number
));
}
}
});
//system 定位
it
(
"
system+type=wgs84+success+altitude=false
"
,
async
()
=>
{
await
page
.
setData
({
jest_provider
:
'
system
'
,
jest_type
:
'
wgs84
'
,
jest_isAltitude
:
false
,
jest_isGeocode
:
true
,
jest_isHighAccuracy
:
false
})
await
page
.
callMethod
(
'
jestGetLocation
'
)
await
page
.
waitFor
(
async
()
=>
{
return
await
page
.
data
(
'
jest_complete
'
)
===
true
;
});
const
data
=
await
page
.
data
()
const
jest_errCode
=
data
[
'
jest_errCode
'
]
if
(
jest_errCode
>
0
)
{
//如果定位出错
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
expect
.
any
(
Number
));
}
else
{
expect
((
await
page
.
data
())[
'
jest_altitude
'
]).
toEqual
(
0
);
}
});
//system 定位
it
(
"
system+type=wgs84+success+altitude=false
"
,
async
()
=>
{
await
page
.
setData
({
jest_provider
:
'
system
'
,
jest_type
:
'
wgs84
'
,
jest_isAltitude
:
false
,
jest_isGeocode
:
true
,
jest_isHighAccuracy
:
false
})
await
page
.
callMethod
(
'
jestGetLocation
'
)
await
page
.
waitFor
(
async
()
=>
{
return
await
page
.
data
(
'
jest_complete
'
)
===
true
;
});
const
data
=
await
page
.
data
()
const
jest_errCode
=
data
[
'
jest_errCode
'
]
if
(
jest_errCode
>
0
)
{
//如果定位出错
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
expect
.
any
(
Number
));
}
else
{
expect
((
await
page
.
data
())[
'
jest_altitude
'
]).
toEqual
(
0
);
}
});
//system 定位
...
...
@@ -118,8 +118,8 @@ describe("get-location", () => {
await
page
.
waitFor
(
async
()
=>
{
return
await
page
.
data
(
'
jest_complete
'
)
===
true
;
});
if
(
isApp
)
{
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
1505601
);
if
(
isApp
)
{
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
1505601
);
}
});
...
...
@@ -138,7 +138,7 @@ describe("get-location", () => {
return
await
page
.
data
(
'
jest_complete
'
)
===
true
;
});
const
data
=
await
page
.
data
()
const
data
=
await
page
.
data
()
const
jest_errCode
=
data
[
'
jest_errCode
'
]
if
(
jest_errCode
>
0
)
{
...
...
@@ -170,8 +170,8 @@ describe("get-location", () => {
await
page
.
waitFor
(
async
()
=>
{
return
await
page
.
data
(
'
jest_complete
'
)
===
true
;
});
if
(
isApp
)
{
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
1505607
);
if
(
isApp
)
{
expect
((
await
page
.
data
())[
'
jest_errCode
'
]).
toEqual
(
1505607
);
}
});
});
});
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录