diff --git a/pages/component/map/map.test.js b/pages/component/map/map.test.js index adfc8bef143cd084e663a6283141b5c300639faa..b5405ebdaee53ff6c5d4280d950f5f269186c3a3 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 fb94420525f2494bad845c98bfb8a3e6abfe3f1a..0ff2de49b3516f3e2063f983205ebc8eeaf305e7 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[]= [{ @@ -344,7 +345,8 @@ longitude: 0 }, moveToLocationMsg: "", - scale: 0, + scale: 0, + eventDetailJsonStringify: "{}" } as TypeJestResult); @@ -665,7 +667,8 @@ }; const onregionchange = (e : UniMapRegionChangeEvent) => { - console.log('视野发生变化时触发', e.detail) + console.log('视野发生变化时触发', e.detail) + jestResult.eventDetailJsonStringify = JSON.stringify(e.detail) }; const onpoitap = (e : UniMapPoiTapEvent) => {