From dfb94557cd314f0fe58af7fb4bea43171c9ef6ee Mon Sep 17 00:00:00 2001 From: Anne_LXM Date: Mon, 27 May 2024 15:54:27 +0800 Subject: [PATCH] =?UTF-8?q?=E8=B0=83=E6=95=B4map=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pages/API/map/map.test.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/pages/API/map/map.test.js b/pages/API/map/map.test.js index 4f19a170..727866f6 100644 --- a/pages/API/map/map.test.js +++ b/pages/API/map/map.test.js @@ -41,11 +41,13 @@ describe('web-map', () => { await page.callMethod('handleGetRegion') await page.waitFor(500); const regionRes = await page.data('getRegionTest') - const getRegionExpected = { - southwest: { latitude: 39.88334279187766, longitude: 116.31050146728515 }, - northeast: { latitude: 40.0149408585477, longitude: 116.56799353271484 }, - errMsg: 'getRegion:ok' - } - expect(regionRes).toEqual(expect.objectContaining(getRegionExpected)); + console.log('regionRes', regionRes); + const {southwest,northeast} = regionRes; + const southwestExp ={ latitude: 39.88334279187766, longitude: 116.31050146728515 } + const northeastExp ={ latitude: 40.0149408585477, longitude: 116.56799353271484 } + expect(southwest.latitude).toBeCloseTo(southwestExp.latitude, 3); + expect(southwest.longitude).toBeCloseTo(southwestExp.longitude, 3); + expect(northeast.latitude).toBeCloseTo(northeastExp.latitude, 3); + expect(northeast.longitude).toBeCloseTo(northeastExp.longitude, 3); }); }); -- GitLab