2022-04-11 08:29:07 +00:00
|
|
|
/*
|
2024-09-09 13:57:16 +00:00
|
|
|
Copyright 2024 New Vector Ltd.
|
2023-02-08 08:31:24 +00:00
|
|
|
Copyright 2022, 2023 The Matrix.org Foundation C.I.C.
|
2022-04-11 08:29:07 +00:00
|
|
|
|
2024-09-09 13:57:16 +00:00
|
|
|
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
|
|
|
|
Please see LICENSE files in the repository root for full details.
|
2022-04-11 08:29:07 +00:00
|
|
|
*/
|
|
|
|
|
|
|
|
import React from "react";
|
2022-12-18 23:17:15 +00:00
|
|
|
import * as maplibregl from "maplibre-gl";
|
2023-02-08 08:31:24 +00:00
|
|
|
import { render, screen } from "@testing-library/react";
|
2022-04-11 08:29:07 +00:00
|
|
|
|
|
|
|
import ZoomButtons from "../../../../src/components/views/location/ZoomButtons";
|
|
|
|
|
|
|
|
describe("<ZoomButtons />", () => {
|
2022-12-18 23:17:15 +00:00
|
|
|
const mapOptions = { container: {} as unknown as HTMLElement, style: "" };
|
|
|
|
const mockMap = new maplibregl.Map(mapOptions);
|
2022-04-11 08:29:07 +00:00
|
|
|
const defaultProps = {
|
|
|
|
map: mockMap,
|
|
|
|
};
|
2023-02-08 08:31:24 +00:00
|
|
|
const getComponent = (props = {}) => render(<ZoomButtons {...defaultProps} {...props} />);
|
2022-04-11 08:29:07 +00:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.clearAllMocks();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("renders buttons", () => {
|
|
|
|
const component = getComponent();
|
2023-02-08 08:31:24 +00:00
|
|
|
expect(component.asFragment()).toMatchSnapshot();
|
2022-04-11 08:29:07 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
it("calls map zoom in on zoom in click", () => {
|
|
|
|
const component = getComponent();
|
2023-02-08 08:31:24 +00:00
|
|
|
screen.getByTestId("map-zoom-in-button").click();
|
2022-04-11 08:29:07 +00:00
|
|
|
|
|
|
|
expect(mockMap.zoomIn).toHaveBeenCalled();
|
|
|
|
expect(component).toBeTruthy();
|
|
|
|
});
|
|
|
|
|
|
|
|
it("calls map zoom out on zoom out click", () => {
|
|
|
|
const component = getComponent();
|
2023-02-08 08:31:24 +00:00
|
|
|
screen.getByTestId("map-zoom-out-button").click();
|
2022-04-11 08:29:07 +00:00
|
|
|
|
|
|
|
expect(mockMap.zoomOut).toHaveBeenCalled();
|
|
|
|
expect(component).toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|