map.test.js 2.5 KB
Newer Older
1 2 3 4 5 6 7 8 9
let page;
describe('web-map', () => {
  if (!process.env.uniTestPlatformInfo.startsWith('web')) {
    it('app', () => {
      expect(1).toBe(1)
    })
    return
  }
  beforeAll(async () => {
10
    page = await program.reLaunch('/pages/component/map/map')
11 12 13
    await page.waitFor('view');
    // 等待地图加载完成
    await page.waitFor(4000);
Anne_LXM's avatar
Anne_LXM 已提交
14
    await page.callMethod('updateAutoTest',true)
15 16 17
  });

  it('Check MapMethods', async () => {
Anne_LXM's avatar
Anne_LXM 已提交
18
    const mapMethods = ['addControls', 'addMarkers', 'addMarkersLabel','addPolyline', 'addPolygons', 'addCircles','includePoint']
19 20
    for (var i = 0; i < mapMethods.length; i++) {
      await page.callMethod(mapMethods[i])
Anne_LXM's avatar
Anne_LXM 已提交
21 22 23 24
      await page.waitFor(500);
      expect(await program.screenshot()).toSaveImageSnapshot({customSnapshotIdentifier() {
        return 'map-' + mapMethods[i]
      }});
25 26 27
      await page.waitFor(500);
    }
  });
Anne_LXM's avatar
Anne_LXM 已提交
28

29 30 31
  it('handleGetCenterLocation', async () => {
    await page.callMethod('handleGetCenterLocation')
    await page.waitFor(500);
Anne_LXM's avatar
Anne_LXM 已提交
32 33 34
    const centerLocationRes = await page.data('jestResult')
    expect(centerLocationRes.centerPoints.latitude).not.toBeNull();
    expect(centerLocationRes.centerPoints.longitude).not.toBeNull();
35
  });
Anne_LXM's avatar
Anne_LXM 已提交
36

37 38 39
  it('handleGetRegion', async () => {
    await page.callMethod('handleGetRegion')
    await page.waitFor(500);
Anne_LXM's avatar
Anne_LXM 已提交
40
    const regionRes = await page.data('jestResult')
Anne_LXM's avatar
Anne_LXM 已提交
41
    const {southwest,northeast} = regionRes;
Anne_LXM's avatar
Anne_LXM 已提交
42 43 44 45
    expect(southwest.latitude).not.toBeFalsy();
    expect(southwest.longitude).not.toBeFalsy();
    expect(northeast.latitude).not.toBeFalsy();
    expect(northeast.longitude).not.toBeFalsy();
46
  });
Anne_LXM's avatar
Anne_LXM 已提交
47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72

  it('handleTranslateMarker', async () => {
    await page.callMethod('handleTranslateMarker')
    await page.waitFor(2000);
    expect(await program.screenshot()).toSaveImageSnapshot();
    const translateMarkerRes = await page.data('jestResult')
    expect(translateMarkerRes.animationEnd).toBeTruthy();
    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')
    await page.waitFor(500);
    const scaleRes = await page.data('jestResult')
    expect(scaleRes.scale).toBeGreaterThanOrEqual(5);
    expect(scaleRes.scale).toBeLessThanOrEqual(18);
    console.log("jestResult",await page.data())
  });

73
});