From 207f278d8dbe3aebe1bd555b47bc73e7ffa5af49 Mon Sep 17 00:00:00 2001 From: taohebin Date: Thu, 28 Nov 2024 18:17:38 +0800 Subject: [PATCH] update: pages/component/map/map.uvue # Conflicts: # pages/component/map/map.uvue --- pages/component/map/map.test.js | 35 +++++++++++++++++++++------------ pages/component/map/map.uvue | 5 ++++- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/pages/component/map/map.test.js b/pages/component/map/map.test.js index adfc8bef..b5405ebd 100644 --- a/pages/component/map/map.test.js +++ b/pages/component/map/map.test.js @@ -1,11 +1,6 @@ let page; describe('web-map', () => { - if (!process.env.uniTestPlatformInfo.startsWith('web')) { - it('app', () => { - expect(1).toBe(1) - }) - return - } + beforeAll(async () => { page = await program.reLaunch('/pages/component/map/map') await page.waitFor('view'); @@ -16,6 +11,26 @@ describe('web-map', () => { await page.callMethod('updateAutoTest',true) }); + it('handleMoveToLocation', async () => { + await page.callMethod('handleMoveToLocation') + await page.waitFor(500); + const moveToLocationRes = await page.data('jestResult') + expect(moveToLocationRes.moveToLocationMsg).toBe("moveToLocation:ok"); + }); + + it('Check EventDetail JsonStringify', async () => { + const res = await page.data('jestResult') + console.log(res.eventDetailJsonStringify); + expect(res.eventDetailJsonStringify).not.toBe("{}"); + }) + + if (!process.env.uniTestPlatformInfo.startsWith('web')) { + it('app', () => { + expect(1).toBe(1) + }) + return + } + it('Check MapMethods', async () => { const mapMethods = ['addControls', 'addMarkers', 'addMarkersLabel','removeMarker','addPolyline','removePolyline', 'addPolygons','removePolygon', 'addCircles','removeCircle','includePoint'] for (var i = 0; i < mapMethods.length; i++) { @@ -58,12 +73,7 @@ describe('web-map', () => { expect(translateMarkerRes.translateMarkerMsg).toBe('translateMarker:ok'); }); - it('handleMoveToLocation', async () => { - await page.callMethod('handleMoveToLocation') - await page.waitFor(500); - const moveToLocationRes = await page.data('jestResult') - expect(moveToLocationRes.moveToLocationMsg).toBe("moveToLocation:ok"); - }); + it('handleGetScale', async () => { await page.callMethod('handleGetScale') @@ -73,5 +83,4 @@ describe('web-map', () => { expect(scaleRes.scale).toBeLessThanOrEqual(18); console.log("jestResult",await page.data()) }); - }); diff --git a/pages/component/map/map.uvue b/pages/component/map/map.uvue index fa6f2da2..d2317ce4 100644 --- a/pages/component/map/map.uvue +++ b/pages/component/map/map.uvue @@ -59,7 +59,8 @@ southwest : LocationObject, northeast : LocationObject, moveToLocationMsg : string, - scale : number + scale : number, + eventDetailJsonStringify: string, } const testMarkers :Marker[]= [{ @@ -345,6 +346,7 @@ }, moveToLocationMsg: "", scale: 0, + eventDetailJsonStringify: "{}" } as TypeJestResult); @@ -666,6 +668,7 @@ const onregionchange = (e : UniMapRegionChangeEvent) => { console.log('视野发生变化时触发', e.detail) + jestResult.eventDetailJsonStringify = JSON.stringify(e.detail) }; const onpoitap = (e : UniMapPoiTapEvent) => { -- GitLab