map.test.js 3.0 KB
Newer Older
1 2
let page;
describe('web-map', () => {
3

4
  beforeAll(async () => {
5
    page = await program.reLaunch('/pages/component/map/map')
6
    await page.waitFor('view');
7
    await page.waitFor('map');
8
    // 等待地图加载完成
9 10
    const waitTime = process.env.uniTestPlatformInfo.includes('firefox') ? 5000:4000
    await page.waitFor(waitTime)
Anne_LXM's avatar
Anne_LXM 已提交
11
    await page.callMethod('updateAutoTest',true)
12 13
  });

14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33
  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
  }

34
  it('Check MapMethods', async () => {
Anne_LXM's avatar
Anne_LXM 已提交
35
    const mapMethods = ['addControls', 'addMarkers', 'addMarkersLabel','removeMarker','addPolyline','removePolyline', 'addPolygons','removePolygon', 'addCircles','removeCircle','includePoint']
36 37
    for (var i = 0; i < mapMethods.length; i++) {
      await page.callMethod(mapMethods[i])
Anne_LXM's avatar
Anne_LXM 已提交
38 39 40 41
      await page.waitFor(500);
      expect(await program.screenshot()).toSaveImageSnapshot({customSnapshotIdentifier() {
        return 'map-' + mapMethods[i]
      }});
42 43 44
      await page.waitFor(500);
    }
  });
Anne_LXM's avatar
Anne_LXM 已提交
45

46 47 48
  it('handleGetCenterLocation', async () => {
    await page.callMethod('handleGetCenterLocation')
    await page.waitFor(500);
Anne_LXM's avatar
Anne_LXM 已提交
49 50 51
    const centerLocationRes = await page.data('jestResult')
    expect(centerLocationRes.centerPoints.latitude).not.toBeNull();
    expect(centerLocationRes.centerPoints.longitude).not.toBeNull();
52
  });
Anne_LXM's avatar
Anne_LXM 已提交
53

54 55 56
  it('handleGetRegion', async () => {
    await page.callMethod('handleGetRegion')
    await page.waitFor(500);
Anne_LXM's avatar
Anne_LXM 已提交
57
    const regionRes = await page.data('jestResult')
Anne_LXM's avatar
Anne_LXM 已提交
58
    const {southwest,northeast} = regionRes;
Anne_LXM's avatar
Anne_LXM 已提交
59 60 61 62
    expect(southwest.latitude).not.toBeFalsy();
    expect(southwest.longitude).not.toBeFalsy();
    expect(northeast.latitude).not.toBeFalsy();
    expect(northeast.longitude).not.toBeFalsy();
63
  });
Anne_LXM's avatar
Anne_LXM 已提交
64 65 66 67

  it('handleTranslateMarker', async () => {
    await page.callMethod('handleTranslateMarker')
    await page.waitFor(2000);
68 69 70
    expect(await program.screenshot()).toSaveImageSnapshot({customSnapshotIdentifier() {
        return 'map-handleTranslateMarker'
      }});
Anne_LXM's avatar
Anne_LXM 已提交
71 72 73 74 75
    const translateMarkerRes = await page.data('jestResult')
    expect(translateMarkerRes.animationEnd).toBeTruthy();
    expect(translateMarkerRes.translateMarkerMsg).toBe('translateMarker:ok');
  });

76

Anne_LXM's avatar
Anne_LXM 已提交
77 78 79 80 81 82 83 84 85

  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())
  });
86
});