Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/utils/location/map.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ export const createMap = (
style: styleUrl,
zoom: 15,
interactive,
attributionControl: false,
});
map.addControl(new maplibregl.AttributionControl(), 'top-right');

map.on('error', (e) => {
logger.error(
Expand Down
4 changes: 4 additions & 0 deletions test/components/views/beacon/BeaconViewDialog-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,10 @@ describe('<BeaconViewDialog />', () => {
const getComponent = (props = {}) =>
mount(<BeaconViewDialog {...defaultProps} {...props} />);

beforeAll(() => {
maplibregl.AttributionControl = jest.fn();
});

beforeEach(() => {
jest.spyOn(OwnBeaconStore.instance, 'getLiveBeaconIds').mockRestore();

Expand Down
5 changes: 5 additions & 0 deletions test/components/views/location/LocationViewDialog-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import React from 'react';
import { mount } from 'enzyme';
import { RoomMember } from 'matrix-js-sdk/src/matrix';
import { LocationAssetType } from 'matrix-js-sdk/src/@types/location';
import maplibregl from 'maplibre-gl';

import LocationViewDialog from '../../../../src/components/views/location/LocationViewDialog';
import { TILE_SERVER_WK_KEY } from '../../../../src/utils/WellKnownUtils';
Expand All @@ -41,6 +42,10 @@ describe('<LocationViewDialog />', () => {
const getComponent = (props = {}) =>
mount(<LocationViewDialog {...defaultProps} {...props} />);

beforeAll(() => {
maplibregl.AttributionControl = jest.fn();
});

it('renders map correctly', () => {
const component = getComponent();
expect(component.find('Map')).toMatchSnapshot();
Expand Down
4 changes: 4 additions & 0 deletions test/components/views/location/Map-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ describe('<Map />', () => {
wrappingComponentProps: { value: matrixClient },
});

beforeAll(() => {
maplibregl.AttributionControl = jest.fn();
});

beforeEach(() => {
jest.clearAllMocks();
matrixClient.getClientWellKnown.mockReturnValue({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,20 @@ exports[`<LocationViewDialog /> renders map correctly 1`] = `
},
"_eventsCount": 1,
"_maxListeners": undefined,
"addControl": [MockFunction],
"addControl": [MockFunction] {
"calls": Array [
Array [
mockConstructor {},
"top-right",
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
},
"fitBounds": [MockFunction],
"removeControl": [MockFunction],
"setCenter": [MockFunction] {
Expand Down Expand Up @@ -78,7 +91,20 @@ exports[`<LocationViewDialog /> renders map correctly 1`] = `
},
"_eventsCount": 1,
"_maxListeners": undefined,
"addControl": [MockFunction],
"addControl": [MockFunction] {
"calls": Array [
Array [
mockConstructor {},
"top-right",
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
},
"fitBounds": [MockFunction],
"removeControl": [MockFunction],
"setCenter": [MockFunction] {
Expand Down
5 changes: 5 additions & 0 deletions test/components/views/messages/MBeaconBody-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,11 @@ describe('<MBeaconBody />', () => {
});

const modalSpy = jest.spyOn(Modal, 'createTrackedDialog').mockReturnValue(undefined);

beforeAll(() => {
maplibregl.AttributionControl = jest.fn();
});

beforeEach(() => {
jest.clearAllMocks();
});
Expand Down
9 changes: 9 additions & 0 deletions test/components/views/messages/MLocationBody-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ describe("MLocationBody", () => {
wrappingComponent: MatrixClientContext.Provider,
wrappingComponentProps: { value: mockClient },
});

beforeAll(() => {
maplibregl.AttributionControl = jest.fn();
});

beforeEach(() => {
jest.clearAllMocks();
});

describe('with error', () => {
let sdkConfigSpy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,20 @@ exports[`MLocationBody <MLocationBody> without error renders map correctly 1`] =
},
"_eventsCount": 1,
"_maxListeners": undefined,
"addControl": [MockFunction],
"addControl": [MockFunction] {
"calls": Array [
Array [
mockConstructor {},
"top-right",
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
],
},
"fitBounds": [MockFunction],
"removeControl": [MockFunction],
"setCenter": [MockFunction] {
Expand All @@ -135,22 +148,12 @@ exports[`MLocationBody <MLocationBody> without error renders map correctly 1`] =
"lon": -0.1276,
},
],
Array [
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Setting the location is still tested some lines above.
Without clearing the mocks it was duplicated.

Object {
"lat": 51.5076,
"lon": -0.1276,
},
],
],
"results": Array [
Object {
"type": "return",
"value": undefined,
},
Object {
"type": "return",
"value": undefined,
},
],
},
"setStyle": [MockFunction],
Expand Down