1 | jest.mock('mapbox-gl', () => ({
|
2 | Map: {}
|
3 | }));
|
4 |
|
5 | jest.mock('../util/overlays', () => ({
|
6 | overlayState: jest.fn(() => ({})),
|
7 | overlayTransform: jest.fn(() => []),
|
8 | anchors: []
|
9 | }));
|
10 |
|
11 | import * as React from 'react';
|
12 | import Popup, { defaultClassName } from '../popup';
|
13 | import { mountWithMap, getMapMock } from '../jest/util';
|
14 |
|
15 | describe('Popup', () => {
|
16 | it('Should render component', () => {
|
17 | const wrapper = mountWithMap(<Popup coordinates={[0, 0]} />, getMapMock());
|
18 | expect(wrapper).toBeDefined();
|
19 | });
|
20 |
|
21 | it('Should add custom className', () => {
|
22 | const wrapper = mountWithMap(
|
23 | <Popup className="custom-classname" coordinates={[0, 0]} />,
|
24 | getMapMock()
|
25 | );
|
26 |
|
27 | expect(wrapper.find('Popup').hasClass('custom-classname')).toEqual(true);
|
28 | });
|
29 |
|
30 | it('Should concat custom className to defaultClassName', () => {
|
31 | const wrapper = mountWithMap(
|
32 | <Popup className="custom-classname" coordinates={[0, 0]} />,
|
33 | getMapMock()
|
34 | );
|
35 |
|
36 | expect(
|
37 | wrapper
|
38 | .find('Popup')
|
39 | .childAt(0)
|
40 | .hasClass(defaultClassName[0])
|
41 | ).toEqual(true);
|
42 | });
|
43 | });
|