1 | import { mount } from 'enzyme';
|
2 | import * as React from 'react';
|
3 | import { MapContext } from '../context';
|
4 | import * as MapboxGl from 'mapbox-gl';
|
5 |
|
6 |
|
7 | export const getMapMock = (override?: { [key: string]: any }) => ({
|
8 | addSource: jest.fn(),
|
9 | removeSource: jest.fn(),
|
10 | addLayer: jest.fn(),
|
11 | on: jest.fn(),
|
12 | off: jest.fn(),
|
13 | setLayerZoomRange: jest.fn(),
|
14 | getLayer: jest.fn(),
|
15 | addImage: jest.fn(),
|
16 | loadImage: jest.fn(),
|
17 | removeImage: jest.fn(),
|
18 | hasImage: jest.fn(),
|
19 | getSource: jest.fn().mockReturnValue({ setData: jest.fn() }),
|
20 | project: jest.fn(),
|
21 | ...override
|
22 | });
|
23 |
|
24 |
|
25 | export const mountWithMap = (comp: JSX.Element, mapValue: any) => {
|
26 | return mount(
|
27 | <MapContext.Provider value={mapValue}>{comp}</MapContext.Provider>
|
28 | );
|
29 | };
|
30 |
|
31 | export class MockComponent extends React.Component<{
|
32 | id: string;
|
33 | map: MapboxGl.Map;
|
34 | }> {
|
35 | public render() {
|
36 | return <h1>{this.props.id}</h1>;
|
37 | }
|
38 | }
|