diff --git a/pages/API/map/map.test.js b/pages/API/map/map.test.js index 4f19a170c32579d98c03ac237c0fc7b9a7d3dcf6..727866f6b68300ded824230a4aea9397e0d6e143 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); }); });