From b01bec96065c5d968e15b29ec0b40c9ebcec6679 Mon Sep 17 00:00:00 2001 From: zhenyuWang <13641039885@163.com> Date: Sat, 7 Dec 2024 16:41:22 +0800 Subject: [PATCH] =?UTF-8?q?test(getLocation):=20=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=EF=BC=8C=E8=A7=84=E9=81=BF=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=E5=B9=B3=E5=8F=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/get-location/get-location.test.js | 128 ++++++++++---------- 1 file changed, 64 insertions(+), 64 deletions(-) diff --git a/pages/API/get-location/get-location.test.js b/pages/API/get-location/get-location.test.js index 45226400..3f8babe6 100644 --- a/pages/API/get-location/get-location.test.js +++ b/pages/API/get-location/get-location.test.js @@ -1,26 +1,26 @@ -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); } }); -}); +}); -- GitLab